src/pyams_skin/resources/js/ext/flot/jquery.flot.touch.min.js
changeset 565 318533413200
parent 564 a1c75f3e0bc7
child 566 a1707c607eec
equal deleted inserted replaced
564:a1c75f3e0bc7 565:318533413200
     1 !function(t){"use strict";function e(t,e){function n(e){var n=t.getOptions();(n.pan.active||n.zoom.active)&&(h(e),v.dispatchEvent(new CustomEvent("touchevent",{detail:e})),g(e)?o(e,"pinch"):(o(e,"pan"),d(e)||(c(e)&&o(e,"doubleTap"),o(e,"tap"),o(e,"longTap"))))}function o(t,e){switch(e){case"pan":f[t.type](t);break;case"pinch":w[t.type](t);break;case"doubleTap":y.onDoubleTap(t);break;case"longTap":x[t.type](t);break;case"tap":L[t.type](t)}}function a(){l.prevTap={x:l.currentTap.x,y:l.currentTap.y}}function r(t){l.currentTap={x:t.touches[0].pageX,y:t.touches[0].pageY}}function u(t){l.tapStartTime=(new Date).getTime(),l.interceptedLongTap=!1,l.currentTapStart={x:t.touches[0].pageX,y:t.touches[0].pageY},l.currentTapEnd={x:t.touches[0].pageX,y:t.touches[0].pageY}}function p(t){l.currentTapEnd={x:t.touches[0].pageX,y:t.touches[0].pageY}}function c(t){var e=(new Date).getTime(),n=e-l.prevTapTime;return n>=0&&n<E&&s(l.prevTap.x,l.prevTap.y,l.currentTap.x,l.currentTap.y)<m?(t.firstTouch=l.prevTap,t.secondTouch=l.currentTap,!0):(l.prevTapTime=e,!1)}function i(e){l.isUnsupportedGesture||(e.preventDefault(),t.getOptions().propagateSupportedGesture||e.stopPropagation())}function s(t,e,n,o){return Math.sqrt((t-n)*(t-n)+(e-o)*(e-o))}function T(t){return t.touches&&0===t.touches.length}function d(t){return l.twoTouches&&1===t.touches.length}function h(t){t.touches.length>=3?l.isUnsupportedGesture=!0:l.isUnsupportedGesture=!1}function g(e){return!!(e.touches&&e.touches.length>=2&&e.touches[0].target===t.getEventHolder()&&e.touches[1].target===t.getEventHolder())}var v,l={twoTouches:!1,currentTapStart:{x:0,y:0},currentTapEnd:{x:0,y:0},prevTap:{x:0,y:0},currentTap:{x:0,y:0},interceptedLongTap:!1,isUnsupportedGesture:!1,prevTapTime:null,tapStartTime:null,longTapTriggerId:null},m=20,E=500,f={touchstart:function(t){a(),r(t),u(t),v.dispatchEvent(new CustomEvent("panstart",{detail:t}))},touchmove:function(t){i(t),r(t),p(t),l.isUnsupportedGesture||v.dispatchEvent(new CustomEvent("pandrag",{detail:t}))},touchend:function(t){i(t),d(t)?(v.dispatchEvent(new CustomEvent("pinchend",{detail:t})),v.dispatchEvent(new CustomEvent("panstart",{detail:t}))):T(t)&&v.dispatchEvent(new CustomEvent("panend",{detail:t}))}},w={touchstart:function(t){v.dispatchEvent(new CustomEvent("pinchstart",{detail:t}))},touchmove:function(t){i(t),l.twoTouches=g(t),l.isUnsupportedGesture||v.dispatchEvent(new CustomEvent("pinchdrag",{detail:t}))},touchend:function(t){i(t)}},y={onDoubleTap:function(t){i(t),v.dispatchEvent(new CustomEvent("doubletap",{detail:t}))}},x={touchstart:function(t){x.waitForLongTap(t)},touchmove:function(t){},touchend:function(t){l.longTapTriggerId&&(clearTimeout(l.longTapTriggerId),l.longTapTriggerId=null)},isLongTap:function(t){return(new Date).getTime()-l.tapStartTime>=1500&&!l.interceptedLongTap&&s(l.currentTapStart.x,l.currentTapStart.y,l.currentTapEnd.x,l.currentTapEnd.y)<20&&(l.interceptedLongTap=!0,!0)},waitForLongTap:function(t){l.longTapTriggerId||(l.longTapTriggerId=setTimeout(function(){x.isLongTap(t)&&v.dispatchEvent(new CustomEvent("longtap",{detail:t})),l.longTapTriggerId=null},1500))}},L={touchstart:function(t){l.tapStartTime=(new Date).getTime()},touchmove:function(t){},touchend:function(t){L.isTap(t)&&(v.dispatchEvent(new CustomEvent("tap",{detail:t})),i(t))},isTap:function(t){return(new Date).getTime()-l.tapStartTime<=125&&s(l.currentTapStart.x,l.currentTapStart.y,l.currentTapEnd.x,l.currentTapEnd.y)<20}};(!0===e.pan.enableTouch||e.zoom.enableTouch)&&(t.hooks.bindEvents.push(function(t,e){v=e[0],e[0].addEventListener("touchstart",n,!1),e[0].addEventListener("touchmove",n,!1),e[0].addEventListener("touchend",n,!1)}),t.hooks.shutdown.push(function(t,e){e[0].removeEventListener("touchstart",n),e[0].removeEventListener("touchmove",n),e[0].removeEventListener("touchend",n),l.longTapTriggerId&&(clearTimeout(l.longTapTriggerId),l.longTapTriggerId=null)}))}jQuery.plot.plugins.push({init:function(t){t.hooks.processOptions.push(e)},options:{propagateSupportedGesture:!1},name:"navigateTouch",version:"0.3"})}();