var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; }; if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } } { let window = _____WB$wombat$assign$function_____("window"); let self = _____WB$wombat$assign$function_____("self"); let document = _____WB$wombat$assign$function_____("document"); let location = _____WB$wombat$assign$function_____("location"); let top = _____WB$wombat$assign$function_____("top"); let parent = _____WB$wombat$assign$function_____("parent"); let frames = _____WB$wombat$assign$function_____("frames"); let opener = _____WB$wombat$assign$function_____("opener"); /** * @author 剧中人 * @github github.com/bh-lay/toucher * @modified 2016-5-25 23:27 * */ (function(global,doc,factoryFn){ /初始化toucher主方法 var factory = factoryFn(global,doc); /提供window.util.toucher()接口 global.util = global.util || {}; global.util.toucher = global.util.toucher || factory; /提供CommonJS规范的接口 global.define && define(function(require,exports,module){ return factory; }); })(this,document,function(window,document){ /** * class 操作 */ var supports_classList = !!document.createElement('div').classList, / 是否含有某个 class hasClass = supports_classList ? function( node, classSingle ){ return node && node.classList && node.classList.contains( classSingle ); } : function ( node, classSingle ){ if( !node || typeof( node.className ) !== 'string' ){ return false; } return !! node.className.match(new RegExp('(\\s|^)' + classSingle + '(\\s|$)')); }; var supportTouch = "ontouchend" in document ? true : false; /** * @method 事件触发器 * @description 根据事件最原始被触发的target,逐级向上追溯事件绑定 * * @param string 事件名 * @param object 原生事件对象 */ function EMIT(eventName,e){ this._events = this._events || {}; /事件堆无该事件,结束触发 if(!this._events[eventName]){ return; } /记录尚未被执行掉的事件绑定 var rest_events = this._events[eventName]; /从事件源:target开始向上冒泡 var target = e.target; while (1) { /若没有需要执行的事件,结束冒泡 if(rest_events.length ==0){ return; } /若已经冒泡至顶,检测顶级绑定,结束冒泡 if(target == this.dom || !target){ /遍历剩余所有事件绑定 for(var i=0,total=rest_events.length;i= Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down'); } /** * 监听原生的事件,主动触发模拟事件 * */ function eventListener(DOM){ var this_touch = this; /轻击开始时间 var touchStartTime = 0; /记录上一次点击时间 var lastTouchTime = 0; /记录初始轻击的位置 var x1,y1,x2,y2; /轻击事件的延时器 var touchDelay; /测试长按事件的延时器 var longTap; /记录当前事件是否已为等待结束的状态 var isActive = false; /记录有坐标信息的事件 var eventMark = null; /单次用户操作结束 function actionOver(e){ isActive = false; clearTimeout(longTap); clearTimeout(touchDelay); } /断定此次事件为轻击事件 function isSingleTap(){ actionOver(); EMIT.call(this_touch,'singleTap',eventMark); } /触屏开始 function touchStart(e){ /缓存事件 eventMark = e; x1 = e.touches[0].pageX; y1 = e.touches[0].pageY; x2 = 0; y2 = 0; isActive = true; touchStartTime = new Date(); EMIT.call(this_touch,'swipeStart',e); /检测是否为长按 clearTimeout(longTap); longTap = setTimeout(function(){ actionOver(e); /断定此次事件为长按事件 EMIT.call(this_touch,'longTap',e); },500); } /触屏结束 function touchend(e){ /touchend中,拿不到坐标位置信息,故使用全局保存下数据 e.plugStartPosition = eventMark.plugStartPosition; e.plugTouches = eventMark.touches; EMIT.call(this_touch,'swipeEnd',e); if(!isActive){ return; } var now = new Date(); /若未监听doubleTap,直接响应 if(!this_touch._events.doubleTap || this_touch._events.doubleTap.length == 0){ isSingleTap(); }else if(now - lastTouchTime > 200){ /延迟响应 touchDelay = setTimeout(isSingleTap,190); }else{ clearTimeout(touchDelay); actionOver(e); /断定此次事件为连续两次轻击事件 EMIT.call(this_touch,'doubleTap',eventMark); } lastTouchTime = now; } /手指移动 function touchmove(e){ /缓存事件 eventMark = e; /在原生事件基础上记录初始位置(为swipe事件增加参数传递) e.plugStartPosition = { pageX : x1, pageY : y1 }; /断定此次事件为移动事件 EMIT.call(this_touch,'swipe',e); if(!isActive){ return; } x2 = e.touches[0].pageX; y2 = e.touches[0].pageY; if(Math.abs(x1-x2)>2 || Math.abs(y1-y2)>2){ /断定此次事件为移动手势 var direction = swipeDirection(x1, x2, y1, y2); EMIT.call(this_touch,'swipe' + direction,e); }else{ /断定此次事件为轻击事件 isSingleTap(); } actionOver(e); } if (supportTouch) { DOM.addEventListener('touchstart',touchStart); DOM.addEventListener('touchend',touchend); DOM.addEventListener('touchmove',touchmove); DOM.addEventListener('touchcancel',actionOver); } else { DOM.addEventListener('MSPointerDown',touchStart); DOM.addEventListener('pointerdown',touchStart); DOM.addEventListener('MSPointerUp',touchend); DOM.addEventListener('pointerup',touchend); DOM.addEventListener('MSPointerMove',touchmove); DOM.addEventListener('pointermove',touchmove); DOM.addEventListener('MSPointerCancel',actionOver); DOM.addEventListener('pointercancel',actionOver); } } /** * touch类 * */ function Touch(DOM,param){ var param = param || {}; this.dom = DOM; /存储监听事件的回调 this._events = {}; /监听DOM原生事件 eventListener.call(this,this.dom); } /** * @method 增加事件监听 * @description 支持链式调用 * * @param string 事件名 * @param [string] 事件委托至某个class(可选) * @param function 符合条件的事件被触发时需要执行的回调函数 * **/ Touch.prototype.on = function ON(eventStr,a,b){ var className,fn; if(typeof(a) == 'string'){ className = a.replace(/^\./,''); fn = b; }else{ className = null; fn = a; } /检测callback是否合法,事件名参数是否存在· if(typeof(fn) == 'function' && eventStr && eventStr.length){ var eventNames = eventStr.split(/\s+/); for(var i=0,total=eventNames.length;i<total;i++){ var eventName = eventNames[i]; /事件堆无该事件,创建一个事件堆 if(!this._events[eventName]){ this._events[eventName] = []; } this._events[eventName].push({ className : className, fn : fn }); } } /提供链式调用的支持 return this; }; /对外提供接口 return function (dom){ return new Touch(dom); }; }); } /* FILE ARCHIVED ON 14:14:14 Apr 07, 2022 AND RETRIEVED FROM THE INTERNET ARCHIVE ON 15:58:51 Feb 07, 2025. JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. SECTION 108(a)(3)). */ /* playback timings (ms): captures_list: 0.828 exclusion.robots: 0.039 exclusion.robots.policy: 0.023 esindex: 0.014 cdx.remote: 42.902 LoadShardBlock: 443.771 (3) PetaboxLoader3.datanode: 178.762 (4) PetaboxLoader3.resolve: 219.89 (2) load_resource: 178.724 */