RyanMullins / angular-hammer

Hammer.js v2 support for AngularJS
http://ryanmullins.github.io/angular-hammer/
MIT License
188 stars 55 forks source link

Pressup not fired when pointer leaves boundaries of initial press container #30

Closed gregtzar closed 9 years ago

gregtzar commented 9 years ago

I need to fire a handler when the user touches down on a div element and also when the user releases the touch. In the old monospaced/hammer library I used the touchdown and touchrelease, and touchrelease was fired when the user released the touch which included when they dragged their finger out of bounds. The new press and pressup implementation does not seem to support this use case. I think we either need to fire pressup when the pointer leaves div boundaries, or allow it to still be fired even after the pointer has left the boundaries. Currently if the user presses down inside the div and then drags outside of it and releases, pressup is never fired.

RyanMullins commented 9 years ago

Can you verify that this behavior works in a stock Hammer.js setup? If it does I'll look into fixing it here, otherwise I won't be able to do anything. I suspect that it won't, given my previous endeavors debugging Hammer Gestures.

In the meantime, you could try using ng-mouseleave to fire the same event handler when the finger leaves the target element (which works unless you care about how long the touch is down).

gregtzar commented 9 years ago

@RyanMullins Good call, I will put together a test case then and get back to you. I think ng-mouseleave would be a sufficient workaround so thanks for throwing that out there. I was also thinking about a custom recognizer that uses mouseleave as another workaround.

gregtzar commented 9 years ago

You are right, this is an issue with hammer.js. And actually the issue is not caused by going outside the container but by dragging before releasing. I see it as a regression but they might not see it that way. I filed and issue with hammer here: https://github.com/hammerjs/hammer.js/issues/751.

RyanMullins commented 9 years ago

Thanks for looking into this. Sorry I couldn't be more help.

gregtzar commented 9 years ago

No worries, I should have done my due diligence before posting. I am still at a loss for a suitable workaround so I am considering ditching hammer all together and just rolling my own touchstart and touchend directives. Unfortunately ngTouch does not provide these either!