demo20230512/Scripts/kendo/2014.2.716/kendo.userevents.min.js

16 lines
6.8 KiB
JavaScript
Raw Normal View History

2023-05-12 10:20:28 +08:00
/**
* Copyright 2014 Telerik AD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
!function(e,define){define(["./kendo.core.min"],e)}(function(){return function(e){function t(e,t){var n=e.x.location,i=e.y.location,r=t.x.location,o=t.y.location,a=n-r,s=i-o;return{center:{x:(n+r)/2,y:(i+o)/2},distance:Math.sqrt(a*a+s*s)}}function n(e){var t,n,i,r=[],a=e.originalEvent,s=e.currentTarget,u=0;if(e.api)r.push({id:2,event:e,target:e.target,currentTarget:e.target,location:e,type:"api"});else if(e.type.match(/touch/))for(n=a?a.changedTouches:[],t=n.length;t>u;u++)i=n[u],r.push({location:i,event:e,target:i.target,currentTarget:s,id:i.identifier,type:"touch"});else r.push(o.pointers||o.msPointers?{location:a,event:e,target:e.target,currentTarget:s,id:a.pointerId,type:"pointer"}:{id:1,event:e,target:e.target,currentTarget:s,location:e,type:"mouse"});return r}function i(e){for(var t=r.eventMap.up.split(" "),n=0,i=t.length;i>n;n++)e(t[n])}var r=window.kendo,o=r.support,a=window.document,s=r.Class,u=r.Observable,l=e.now,c=e.extend,d=o.mobileOS,f=d&&d.android,h=800,p=o.browser.msie?5:0,g="press",m="hold",v="select",y="start",_="move",b="end",w="cancel",x="tap",F="release",k="gesturestart",S="gesturechange",M="gestureend",T="gesturetap",C={api:0,touch:0,mouse:9,pointer:9},D=s.extend({init:function(e,t){var n=this;n.axis=e,n._updateLocationData(t),n.startLocation=n.location,n.velocity=n.delta=0,n.timeStamp=l()},move:function(e){var t=this,n=e["page"+t.axis],i=l(),r=i-t.timeStamp||1;(n||!f)&&(t.delta=n-t.location,t._updateLocationData(e),t.initialDelta=n-t.startLocation,t.velocity=t.delta/r,t.timeStamp=i)},_updateLocationData:function(e){var t=this,n=t.axis;t.location=e["page"+n],t.client=e["client"+n],t.screen=e["screen"+n]}}),z=s.extend({init:function(e,t,n){c(this,{x:new D("X",n.location),y:new D("Y",n.location),type:n.type,threshold:e.threshold||C[n.type],userEvents:e,target:t,currentTarget:n.currentTarget,initialTouch:n.target,id:n.id,pressEvent:n,_moved:!1,_finished:!1})},press:function(){this._holdTimeout=setTimeout(e.proxy(this,"_hold"),this.userEvents.minHold),this._trigger(g,this.pressEvent)},_hold:function(){this._trigger(m,this.pressEvent)},move:function(e){var t=this;if(!t._finished){if(t.x.move(e.location),t.y.move(e.location),!t._moved){if(t._withinIgnoreThreshold())return;if(E.current&&E.current!==t.userEvents)return t.dispose();t._start(e)}t._finished||t._trigger(_,e)}},end:function(e){var t=this;t.endTime=l(),t._finished||(t._finished=!0,t._trigger(F,e),t._moved?t._trigger(b,e):t._trigger(x,e),clearTimeout(t._holdTimeout),t.dispose())},dispose:function(){var t=this.userEvents,n=t.touches;this._finished=!0,this.pressEvent=null,clearTimeout(this._holdTimeout),n.splice(e.inArray(this,n),1)},skip:function(){this.dispose()},cancel:function(){this.dispose()},isMoved:function(){return this._moved},_start:function(e){clearTimeout(this._holdTimeout),this.startTime=l(),this._moved=!0,this._trigger(y,e)},_trigger:function(e,t){var n=this,i=t.event,r={touch:n,x:n.x,y:n.y,target:n.target,event:i};n.userEvents.notify(e,r)&&i.preventDefault()},_withinIgnoreThreshold:function(){var e=this.x.initialDelta,t=this.y.initialDelta;return Math.sqrt(e*e+t*t)<=this.threshold}}),E=u.extend({init:function(t,n){var s,l,d,f=this,C=r.guid();n=n||{},s=f.filter=n.filter,f.threshold=n.threshold||p,f.minHold=n.minHold||h,f.touches=[],f._maxTouches=n.multiTouch?2:1,f.allowSelection=n.allowSelection,f.captureUpIfMoved=n.captureUpIfMoved,f.eventNS=C,t=e(t).handler(f),u.fn.init.call(f),c(f,{element:t,surface:e(n.global?a.documentElement:n.surface||t),stopPropagation:n.stopPropagation,pressed:!1}),f.surface.handler(f).on(r.applyEventMap("move",C),"_move").on(r.applyEventMap("up cancel",C),"_end"),t.on(r.applyEventMap("down",C),s,"_start"),(o.pointers||o.msPointers)&&t.css("-ms-touch-action","pinch-zoom double-tap-zoom"),n.preventDragEvent&&t.on(r.applyEventMap("dragstart",C),r.preventDefault),t.on(r.applyEventMap("mousedown",C),s,{root:t},"_select"),f.captureUpIfMoved&&o.eventCapture&&(l=f.surface[0],d=e.proxy(f.preventIfMoving,f),i(function(e){l.addEventListener(e,d,!0)})),f.bind([g,m,x,y,_,b,F,w,k,S,M,T,v],n)},preventIfMoving:function(e){