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?
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.
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.
I had the same problem.
Commented preventDefault() and now everything is working fine.
Thanks kaij!
I hope that someone fixes this.
Most helpful comment
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.