jeromeetienne / virtualjoystick.js

a virtual joystick library to emulate a joystick on touch screen in javascript
http://jeromeetienne.github.com/virtualjoystick.js/examples/basic.html
MIT License
417 stars 125 forks source link

Set event listener passive option to false #42

Open dunstad opened 5 years ago

dunstad commented 5 years ago

In chrome on the dual.html example, I see this error:

[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080

It can be fixed by changing these lines:

this.container.addEventListener( 'touchstart' , this.$onTouchStart , false, ); this.container.addEventListener( 'touchend' , this.$onTouchEnd , false ); this.container.addEventListener( 'touchmove' , this.$onTouchMove , false );

as follows:

this.container.addEventListener( 'touchstart' , this.$onTouchStart , {capture: false, passive: false} ); this.container.addEventListener( 'touchend' , this.$onTouchEnd , {capture: false, passive: false} ); this.container.addEventListener( 'touchmove' , this.$onTouchMove , {capture: false, passive: false} );