其他分享
首页 > 其他分享> > vux scroller在iOS13上,一停止滑动就跳到顶部

vux scroller在iOS13上,一停止滑动就跳到顶部

作者:互联网

找到 \node_modules\vux-xscroll\build\cmd\simulate-scroll.js文件,对其中的getScrollTop方法重写,

  getScrollTop: function() {
    // var transY = window.getComputedStyle(this.container)[transform].match(/[-\d\.*\d*]+/g);
    
    var transY = window.getComputedStyle(this.container)[transform].match(/[-\d\.*\d*e\-\d]+/g);
    return transY ? Math.round(transY[5]) === 0 ? 0 : -Math.round(transY[5]) : 0;
  },

该方法校验transform的正则( /[-\d\.*\d*]+/g  )不能满足新版本 ,所以匹配iOS13会出现得到 
transY  = ["1", "-2.4492935982947064", "-16", "2.4492935982947064", "-16", "1", "0", "19.48200035095215"]的结果。
getScrollTop得到的返回值为-Math.round(transY[5]) 的时候永远为-1,这也就是为什么获取到的scrollTop的值总是会变成-1。
 

 

标签:iOS13,transY,scroller,getScrollTop,transform,vux,2.4492935982947064,round,Math
来源: https://blog.csdn.net/littleGreenTrain/article/details/104789309