Skip to content

Touch event default behaviours disabled in control preventing scrolling #3253

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

Closed
kaij opened this issue Feb 19, 2015 · 3 comments
Closed

Touch event default behaviours disabled in control preventing scrolling #3253

kaij opened this issue Feb 19, 2015 · 3 comments

Comments

@kaij
Copy link

kaij commented Feb 19, 2015

I added a custom control to a map containing a scrollable list. This list is not scrollable on touch platforms (but works normal on desktop/mouse interaction).

Reason: ol.pointer.TouchSource.prototype.touchmove calls preventDefault on the event, therefore disabling normal touch scrolling behaviour on the target control. Comment out the preventDefault call and everything works.

Why is preventDefault called? If it is really needed, how could I cleanly implement touch scrolling?

@kaij
Copy link
Author

kaij commented Feb 19, 2015

I found a nice solution by looking at the hierarchy of event propagation. OL handles the touchmove event as last handler. So I catch touchstart,touchmove,touchend for my control and call stopPropagation to prevent the event from going through to OL. Scrolling works now nicely.

@kaij kaij closed this as completed Feb 19, 2015
@tsauerwein
Copy link
Member

Nice that you found a work-around! I am not 100% sure anymore why this preventDefault was necessary. Maybe to avoid that panning the map scrolls the page, but maybe this also handled else where.

I think you could also show the list not as an ol control, but simply as a container with position absolute and a high z-index. By doing that you should get the event before the listener on the map.

@davidpinheiro
Copy link

I had the same problem.
Commented preventDefault() and now everything is working fine.
Thanks kaij!
I hope that someone fixes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants