IScroll - saving your own vertical scroll - works in iOS, not in Android

I use iScroll.js to scroll the items carousel on the mobile page. I found the following fix that listens for vertical movement and stops iScroll script control, allowing me to execute my own vertical scroll:

onBeforeScrollStart: function(e) { try { point = e.touches[0]; pointStartX = point.pageX; pointStartY = point.pageY; } catch(e) {} null; }, onBeforeScrollMove: function(e) { try { deltaX = Math.abs(point.pageX - pointStartX); deltaY = Math.abs(point.pageY - pointStartY); if (deltaX >= deltaY) { e.preventDefault(); } else { null; } } catch(e) {} } 

I use try {} catch {}, because it had some problems when testing in the browser (complained that the point was not defined).

The problem I am facing is that it works well on iOS, has been tested on multiple i-devices, but on Android it is not so good. If the user tries to scroll the page vertically, starting with placing a finger on the carousel, the page does not scroll, since iScroll still has control.

Any idea how I can make it work on Android, or any pointers to where this might go wrong?

Edit:

Some debugging, and I discovered why this is not working. The coordinates are updated when the user touches the screen on iOS, but on Android only the first set of coordinates is captured. Any idea why this would be?

+7
source share
2 answers

It looks like you don't have a β€œpoint” in your area for onBeforeScrollMove. In addition, some Android devices can trigger multitouch click events (I cannot confirm this, but only theorize due to platform fragmentation)

I have a nice script that I will release soon that accepts click events and simulates a unique multitouch event, using the β€œmouse” as an identifier property to the touch, which can be w / debugging with some help. I will try to make the project appear on the network by tomorrow night.

This is due to the addition of several updates and projects, but here is the link:

https://github.com/skhameneh

EDIT: Correction, are you even updating the β€œpoint”? It appears to be outside this part of the code and modified internally. It may be useful if you post the rest of your code.

0
source

The creator of iScroll actually has a port that seems to work just like you describe, swapping horizontally and still allowing vertical scrolling. https://github.com/cubiq/2-way-iScroll

0
source

All Articles