iScroll还提供额一些你可以挂靠的有用的自定义事件。
使用on(type, fn)方法注册事件。
myScroll = new IScroll('#wrapper');
myScroll.on('scrollEnd', doSomething);
上面的代码会在每次滚动停止是执行doSomething方法。
可以挂靠的事件如下:
scroll-probe.js版本中有效,请参考onScroll event。The scroll event is available on iScroll probe edition only (iscroll-probe.js). The probe behavior can be altered through the probeType option.
scroll事件在iScroll probe edition版本中有效(仅包含在iscroll-probe.js脚本文件中)。可以通过改变probeType选项值来改变scroll事件的触发时机。
这个属性是调节在scroll事件触发中探针的活跃度或者频率。有效值有:1, 2, 3。数值越高表示更活跃的探测。探针活跃度越高对CPU的影响就越大。
probeType: 1 对性能没有影响。scroll事件只有在滚动条不繁忙的时候触发。
probeType: 2 除了在势能和反弹范围内,将在scroll事件周期内一直执行。这类似于原生的onScroll事件。
probeType: 3 像素级的触发scroll事件。注意,此时滚动只关注requestAnimationFrame (即:useTransition:false).
请参考 probe demo.