您好,欢迎来到伴沃教育。
搜索
您的当前位置:首页手持设备响应速度优化之-click和touch

手持设备响应速度优化之-click和touch

来源:伴沃教育
手持上click事件的响应速度远远不如touchstart。但是仅仅写touch事件很不方便web端开发测试,所以下边的判断很有必要。###

<pre>
var isSupportTouch = "ontouchend" in document ? true : false,
touchEv = isSupportTouch ? 'touchstart' : 'mousedown',
touchEndEv = isSupportTouch ? "touchend" : 'mouseup';
</pre>
另外:
<pre>
var isSupportTouch = "ontouchend" in document ? true : false,
touchEv = isSupportTouch ? 'touchstart' : 'click';
</pre>
用起来就很方便啦
<pre>
$obj.on(touchEv,function(){
\事件
});
</pre>

Copyright © 2019- bangwoyixia.com 版权所有 湘ICP备2023022004号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务