大家好,又见面了,我是你们的朋友全栈君。
今天遇到一个问题,在优化touchmove时候使用了防抖,touchmove和touchend中都改变了元素的样式,问题就产生了。
函数节流和防抖都是使用setTimeout做延时,当拖动动作完成之后会触发touchend,touchmove有延时,可能会造成touchend执行之后才执行了touchmove
解决办法可以给touchend加一个setTimeout,delay大于节流或者防抖的时间间隔
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/129302.html原文链接:https://javaforall.net