This topic created in 2628 days ago, the information mentioned may be changed or developed.
https://weui.io/首页菜单点击的风琴折叠动作
我看 example.js 里创见了 TouchEvent 事件,然后在菜单的 div 中有 touchstart 和 touchend 事件监听,但是这个事件监听是用什么方法挂载这个 div 上的阿
3 replies • 2019-03-28 15:29:32 +08:00
 |
|
1
shuperjolly Mar 28, 2019
应该是这个函数 function fastClick(){ var supportTouch = function(){ try { document.createEvent("TouchEvent"); return true; } catch (e) { return false; } }(); var _old$On = $.fn.on;
$.fn.on = function(){ if(/click/.test(arguments[0]) && typeof arguments[1] == 'function' && supportTouch){ var touchStartY, callback = arguments[1]; _old$On.apply(this, ['touchstart', function(e){ touchStartY = e.changedTouches[0].clientY; }]); _old$On.apply(this, ['touchend', function(e){ if (Math.abs(e.changedTouches[0].clientY - touchStartY) > 10) return;
e.preventDefault(); callback.apply(this, [e]); }]); }else{ _old$On.apply(this, arguments); } return this; }; }
$.fn.on 这个是监听添加,但是这里面这个函数有老鸟帮忙说说什么逻辑吗
|
 |
|
2
lukaz Mar 28, 2019 1
页面 js,$('.js_category').on('click', function(){ ... })
|
 |
|
3
shuperjolly Mar 28, 2019
@ lukaz 为什么它在页面 js 的这个标签里面加 class="home js_show",有什么作用啊
|