-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Page scrolling not deactivated on Firefox Mobile when panning on fixed overlay div #8
Comments
@tedbarth Thank you! I'll check it :) |
@tedbarth I found abnormal behavior in FireFox mobile. Reason for failDespite the Firefox mobile(Android). 62.0.3 supports touch-action, It is invalidated when event listener is registered(by addEventListener). In your demo, .overlay {
touch-action: none; // hammer.js sets this value when browser support it.
}
const overlay = document.querySelector('.overlay');
// following code invalidate behavior of touch-action in FireFox Mobile
overlay.addEventListener("touchstart", e => {
}); It works fine as expected in other browser. But Firefox mobile does not. Solution ?It can be solved by making const overlay = document.querySelector('.overlay');
overlay.addEventListener("touchstart", e => {
e.preventDefault();
}); But I'm not sure is it right to handle it using the @tedbarth How do you think about it? I would like to hear your advice. |
Alternative (Temporary)After some consideration, I found an temporary measure until firefox android fix this issue. const isAndroidFirefox = /* */;
const overlay = document.querySelector('.overlay');
if (isAndroidFirefox) {
// hook touchstart event & call preventDefault.
overlay.addEventListener("touchstart", e => {
e.preventDefault(); // prevent if direction isn't 'none'
});
}
const hammer = new Hammer(overlay);
hammer.get('pan').set({direction: Hammer.DIRECTION_ALL}); |
Thanks for the fast investigation! The workaround indeed solves the problem and does not hurt for most of the cases. I thought about a possible solution and wondered why we cannot use e.preventDefault() per se. I doubt that if one registers a pan, pinch or whatever hammer.js event, you don't want the default behavior on top. There is no "pinch" event the browser could have default behaviors as there is no "pan" behavior the developer expect to get triggered: Those are new events and the only behavior you'd expect is that what you've programmed yourself. I haven't got enough knowledge about event handling in browsers, though. Maybe I'm totally wrong. Maybe there are other use cases I'm just not aware of, but for the moment I think the default behavior could be blocked. Anyway I would say that for the moment calling preventDefault for Firefox could be hardcoded until there is a fix. BTW: Some days ago Mozilla released a new Firefox / Firefox Mobile version 63.0.1. Maybe it's already fixed? |
@tedbarth It would be better to add some explain.
There's two way for blocking default action. 1. By specifying touch-action in HTML
2. preventDefault() in touch event handler
But In this case, Although FireFox Mobile(Android) supports
And I'll report it firefox bug report. |
I reported it on firefox bug report |
Closing this issue due to inactivity. |
On Firefox Mobile the page scrolling is not deactivated when panning on an fixed, 100% height/width overlay div. All other tested browsers work just fine.
The issue happened on some kind of gallery app. I could isolate the problem again as an example page here (Project has been updated):
https://github.com/tedbarth/hammerjs-demo
If you need more information, please let me know. Thanks for the investigation!
The text was updated successfully, but these errors were encountered: