你的位置:首页 > 软件开发 > Java > 解决iSlider的一些问题(滑动组件)

解决iSlider的一些问题(滑动组件)

发布时间:2016-07-26 20:00:05
一:先解决一下该插件在PC端(针对数据内容是html)滑动性能的问题,反正就是在PC端滑动体验不好。针对这个问题我先去监测了组件里滑动时evt.pageX , this.startX(鼠标按下去的)这两个的值变化,结果发现那个evt.pageX滑动到一定的距离后跟实际鼠标位置 ...

一:先解决一下该插件在PC端(针对数据内容是html)滑动性能的问题,反正就是在PC端滑动体验不好。

针对这个问题我先去监测了组件里滑动时evt.pageX , this.startX(鼠标按下去的)这两个的值变化,结果发现那个evt.pageX滑动到一定的距离后跟实际鼠标位置的值不匹配,在进一步才发现他提前执行了endHandler以至this.onMoving 设置成了false,然后后面就不会滑动了。

仔细看了下代码,组件给PC端执行了如下代码

 !device.hasTouch && outer.addEventListener('mouseout', this);//组件原本的mouseout事件代码
注意closest方法用原生JavaScript替代jQuery的closest方法,目前只有现代浏览器本身就支持。如果需要兼容ie9(目前我测试至少在ie9及以上是OK的),则加入以下代码
//原文出处1:http://www.codesec.net/view/206139.html 2:https://plainjs.com/javascript/traversing/match-element-selector-52//*******匹配DOM上级元素,实现closest()方法,由于在现代浏览器中内置支持了这些元素,因此我们为了获得更好的性能,我们建议在原生对象上进行拓展,就可以像下面这样直接使用:*********/this.Element && function (ElementPrototype) {  ElementPrototype.matches = ElementPrototype.matches ||  ElementPrototype.matchesSelector ||  ElementPrototype.webkitMatchesSelector ||  ElementPrototype.msMatchesSelector ||  function (selector) {    var node = this, nodes = (node.parentNode || node.document).querySelectorAll(selector), i = -1;    while (nodes[++i] && nodes[i] != node);    return !!nodes[i];  }}(Element.prototype);this.Element && function (ElementPrototype) { ElementPrototype.closest = ElementPrototype.closest || function (selector) { var el = this; while (el.matches && !el.matches(selector)) el = el.parentNode; return el.matches ? el : null; 

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:解决iSlider的一些问题(滑动组件)

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录