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
Can´t use moveend on body and expect document scrolling to work on mobile devices. #27
Comments
If you bind a move event to the body, the script assumes you want to move, not scroll, the body. To conditionally suppress scrolling, see the documentation here: |
What I really want is to check if the mouse is released anywhere in the document. (Still having the possibility to scroll the document). I only have a handler 'movestart' in a certain element, not in body. |
Yes I see. You want to delegate moveend to handle all moveends for the document. But moveend cancels scroll because it assumes you're listening for a move, not a scroll. You should be able to set up a movestart also on the body, use it to enable scrolling (by calling .preventDefault() if event.target is not one of the things you want to move), and the moveend handler will still pick up delegates from the things you have moved. It's a bit tricky getting jQuery special events to delegate nicely, and the move events weren't designed with this use case in mind. Should work, though. |
I ended up checking target in the moveStart handler. $('body').on('movestart', function(e)
{
if ($(e.target).closest('.event-slider .scrolled-content').length == 0)
e.preventDefault();
}); Thanks for the help! |
On
https://jsfiddle.net/twjou50r/1/embedded/result/
I have a webpage where scrolling does not work very well on mobile devices.
I am using the emulation in chrome to try this. A phone will also prove the issue.
Problem: Nothing happends when I try to scroll, even if document content is taller than the window.
If I remove the lines
scrolling works as demonstrated on:
https://jsfiddle.net/twjou50r/2/embedded/result/
(if you want to see the source of those jsfiddles, you click "Edit in JSFiddle")
The text was updated successfully, but these errors were encountered: