关于scroll事件和touchmove事件
代码如下:
< scroll-view scroll-y bindscroll = "scroll" bindscrolltoupper = "upper" upper-threshold = "0" > < view capture-bind:touchmove = "handleTouch" capture-bind:touchend = "handleTouchMove" ></ view > </ scroll-view > |
scroll (e) {
if (px > 100) { this .setData({ overlay: true }) } else if (px <= 100) { this .setData({ overlay: false }) } }, handleTouch (e) { if ( this .data.touchScrollTop > 100) { this .setData({ overlay: true }) } else if ( this .data.touchScrollTop <= 100) { this .setData({ overlay: false }) } }, upper (e) { this .setData({ overlay: false }) } |
我通过overlay这个值来给元素增加css class,现在的问题是每次添加或删除样式后,页面元素都是要等0.5秒左右才会变化,请问如何解决这种延迟?