apache / cordova-plugin-device-orientation

Apache Cordova Device Orientation Plugin
https://cordova.apache.org/
Apache License 2.0
58 stars 83 forks source link

CB-9426 Fix exception using device orientation plugin on browser platform #21

Closed TimBarham closed 8 years ago

TimBarham commented 8 years ago

Initially reported for the device motion plugin, the same problem exists for the device orientation plugin.

The plugin's plugin.xml defines a general <js-module> with the name compass. It defines another <js-module> for the browser platform (that merges with the general module) with the same name. Modules with the same name are not allowed, so Cordova throws an exception at runtime when trying to define the browser version of the module.

Since the only difference in the browser version of the module is to fake up deviceorientation events, I've deleted the browser version and added that logic to the general module, with the following change: rather than starting a new event timer every time watchHeading() is called (which could happen multiple times resulting in multiple superfluous timers), we have a single event timer going as long as there are active watchers.

vladimir-kotikov commented 8 years ago

LGTM