16 lines
3.1 KiB
JavaScript
16 lines
3.1 KiB
JavaScript
|
/**
|
||
|
* 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","./kendo.userevents.min"],e)}(function(){return function(e){var t=window.kendo,n=t.ui.Widget,i=e.proxy,r=Math.abs,a=20,o=t.Class.extend({init:function(n,i,a){a=e.extend({minXDelta:30,maxYDelta:20,maxDuration:1e3},a),new t.UserEvents(n,{surface:a.surface,allowSelection:!0,start:function(e){2*r(e.x.velocity)>=r(e.y.velocity)&&e.sender.capture()},move:function(e){var t=e.touch,n=e.event.timeStamp-t.startTime,o=t.x.initialDelta>0?"right":"left";r(t.x.initialDelta)>=a.minXDelta&&r(t.y.initialDelta)<a.maxYDelta&&a.maxDuration>n&&(i({direction:o,touch:t,target:t.target}),t.cancel())}})}}),s=n.extend({init:function(e,r){function a(e){return function(t){s._triggerTouch(e,t)}}function o(e){return function(t){s.trigger(e,{touches:t.touches,distance:t.distance,center:t.center,event:t.event})}}var s=this;n.fn.init.call(s,e,r),r=s.options,e=s.element,s.events=new t.UserEvents(e,{filter:r.filter,surface:r.surface,minHold:r.minHold,multiTouch:r.multiTouch,allowSelection:!0,press:a("touchstart"),hold:a("hold"),tap:i(s,"_tap"),gesturestart:o("gesturestart"),gesturechange:o("gesturechange"),gestureend:o("gestureend")}),r.enableSwipe?(s.events.bind("start",i(s,"_swipestart")),s.events.bind("move",i(s,"_swipemove"))):(s.events.bind("start",i(s,"_dragstart")),s.events.bind("move",a("drag")),s.events.bind("end",a("dragend"))),t.notify(s)},events:["touchstart","dragstart","drag","dragend","tap","doubletap","hold","swipe","gesturestart","gesturechange","gestureend"],options:{name:"Touch",surface:null,global:!1,multiTouch:!1,enableSwipe:!1,minXDelta:30,maxYDelta:20,maxDuration:1e3,minHold:800,doubleTapTimeout:800},cancel:function(){this.events.cancel()},_triggerTouch:function(e,t){this.trigger(e,{touch:t.touch,event:t.event})&&t.preventDefault()},_tap:function(e){var n=this,i=n.lastTap,r=e.touch;i&&n.options.doubleTapTimeout>r.endTime-i.endTime&&t.touchDelta(r,i).distance<a?(n._triggerTouch("doubletap",e),n.lastTap=null):(n._triggerTouch("tap",e),n.lastTap=r)},_dragstart:function(e){this._triggerTouch("dragstart",e)},_swipestart:function(e){2*r(e.x.velocity)>=r(e.y.velocity)&&e.sender.capture()},_swipemove:function(e){var t=this,n=t.options,i=e.touch,a=e.event.timeStamp-i.startTime,o=i.x.initialDelta>0?"right":"left";r(i.x.initialDelta)>=n.minXDelta&&r(i.y.initialDelta)<n.maxYDelta&&n.maxDuration>a&&(t.trigger("swipe",{direction:o,touch:e.touch}),i.cancel())}});window.jQuery.fn.kendoMobileSwipe=function(e,t){this.each(function(){new o(this,e,t)})},t.ui.plugin(s)}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()});
|