microsoftarchive / cordova-pointerevents

cordova-pointerevents
3 stars 1 forks source link

Android. Plugin does not work #1

Open sgrebnov opened 11 years ago

sgrebnov commented 11 years ago

Polyfill is installed, pointer events are fired, but multi-touch does not work and test/tracker sample page reports my touches as mouse instead of touch, to be investigated.. (no such issue if I open same page in android vanilla browser)

sgrebnov commented 11 years ago

Investigation results

Touche listeners are not installed because Polymer relies on the DOMContentLoaded event which should be fired https://github.com/Polymer/PointerEvents/blob/stable/src/installer.js#L81

installOnLoad: function() {
      document.addEventListener('DOMContentLoaded', this.installNewSubtree.bind(this, document));
}

When Polymer is being installed via plugin document.readyState === "interactive" and no 'DOMContentLoaded' event is fired after that.

There is some related discussion here http://mail-archives.apache.org/mod_mbox/incubator-callback-commits/201206.mbox/%3C20120601235227.4EAE5F656@tyr.zones.apache.org%3E

sgrebnov commented 11 years ago

DOMContentLoaded is fired before Polymer code is run

sgrebnov commented 11 years ago

https://developer.mozilla.org/en-US/docs/Web/API/document.readyState

The following workaround can be used. We need to contribute it to Polymer

if (document.readyState === "interactive" || document.readyState === "complete") {
    this.installNewSubtree(document);
  } else {
    document.addEventListener('DOMContentLoaded', this.installNewSubtree.bind(this, document));
}