Hammer JS v2.0.4 does not recognize "panstart" or "panmove" only in Chrome 37.0

I wanted to learn Hammer JS by creating a simple program for dragging an element around the screen, much like on the Hammer page.

I used the code hosted on the Hammer github page, which seems to be the same code used on the main page. I tested work in Chrome (37.0 / OSX). After working with it for a while and was unable to make the element move, I opened the same page in Safari and FF. It worked great in both browsers.

To fix everything, I added only the code needed for the code to see the event trigger:

var mover = document.getElementById("mover"); var mc = new Hammer.Manager(mover); mc.add(new Hammer.Pan({ threshold: 0, pointers: 0 })); mc.on("panstart panmove", function(ev) { console.log(ev); }); 

Nothing is logged in Chrome, but I get proper logging as expected in Safari and FF. I expanded the event listener to include panning, panning, panning, panning, panning, panning, panning, pandown. These events WILL go into Chrome, so it seems that only panstart and panmove are ignored.

This way, this code will be run on the hammer.js page in Chrome, so Chrome always sees panstart and panmove events in this browser, it just doesn't happen in my code. This means that I have something missing, despite the fact that you copy the code from your site. I checked that we were on the same version of Hammer, but I'm not sure what else I need to check from here.

Has anyone else encountered and solved this problem? Or maybe he knows what I'm doing wrong to create this problem?

Thanks.

+5
source share
1 answer

The Hammer website makes it clear: "To improve performance on slower devices, you should try to make callbacks as simple as possible." I think the same with browsers!

Maybe your problem

 var mover = document.getElementById("#mover"); 

Why do you enter "#mover" instead of "mover"? "#" Mean it for jQuery and you are using simple javascript. It confuses me that in some browsers this works, so I imagine that your ElementID starts with "#" ...

Let me know if this helps, please!

-1
source

Source: https://habr.com/ru/post/1204131/


All Articles