Search code examples
androidtargethammer.jspan

Hammer.js - event.target does not change while panning on Android


I'm trying to get Hammer update the event.target element while using the "pan" event on mobile Android (so far only checked 4.2).

The problem is if I attach Hammer to the ul and pan along the li elements the event.target is returned correctly on desktop browsers (Chrome in particular - check the console), but mobile Android event.target is always the first one clicked.

The code:

$(document).ready(function() {
        console.log('fired up!');
        var myParent = document.getElementsByClassName('test')[0];

        var mc = new Hammer.Manager(myParent, {domEvents: true});

        mc.add( new Hammer.Pan({ direction: Hammer.DIRECTION_ALL, threshold: 0 }) );            
        mc.on("pan", function(ev) {
                console.log(ev.target);
            });
    });

An example can be found here:

http://designingreen.net/tests/test-hammer.html (just check the source)

Am I doing something wrong or is it a matter of Hammer?

Edit: Apparently this is an issue in Android and "touchmove" event. A good workaround solution is availible here:

How to find out the actual event.target of touchmove javascript event?


Solution

  • Apparently this is an issue in Android with "touchmove" event. A good workaround solution is availible here:

    How to find out the actual event.target of touchmove javascript event?