I want to call some actions, when the user is scrolling in iScroll4. Also depending on the position and speed on the scrolling.
Where and how to hook in best to achive this?
With addListener I had no luck, because it reacts on on-time events, eg. Touchmove, touchstart. What i need is to know when the div is scrolling..
Any ideas?
The scroll event is available on iScroll probe edition only (iscroll-probe.js). The probe behavior can be altered through the probeType option.
you can include "iscroll-probe.js" in your html and :
There are lot of callback functions
iScroll
. You can use those for your purposes.A small explanation about those.
I just gave you a small explanation about the some of callback functions. But there are some more exists such as
onTouchEnd
,onZoomStart
,onZoom
,onZoomEnd
. You can experiment those if you need.I hope this might help you to sort out issue.
Latest Update to get the position and speed of the scroller.
For your reference
console.log(e)
and analyze the valuee
has. It return lot ofx & y
positions. From those you can get the scroller position directly. But to get the speed of the scroller you have to usephysics
;). It returnstimestamp
,scroller position
. I think you might to able to get the speed using these values. I am sorry at the moment I could not analyze these values to exactly say how you can get thespeed
. But I think you can calculate speed using the values available.