
template.js.flot.jquery.flot.touchNavigate.min.js Maven / Gradle / Ivy
'use strict';(function(q){function u(b,c){function d(a,b){a=a.getOptions();a.zoom.interactive&&a.zoom.enableTouch&&(b[0].addEventListener("pinchstart",k.start,!1),b[0].addEventListener("pinchdrag",k.drag,!1),b[0].addEventListener("pinchend",k.end,!1));a.pan.interactive&&a.pan.enableTouch&&(b[0].addEventListener("panstart",m.start,!1),b[0].addEventListener("pandrag",m.drag,!1),b[0].addEventListener("panend",m.end,!1));a.recenter.interactive&&a.recenter.enableTouch&&b[0].addEventListener("doubletap",
v.recenterPlot,!1)}function g(a,b){b[0].removeEventListener("panstart",m.start);b[0].removeEventListener("pandrag",m.drag);b[0].removeEventListener("panend",m.end);b[0].removeEventListener("pinchstart",k.start);b[0].removeEventListener("pinchdrag",k.drag);b[0].removeEventListener("pinchend",k.end);b[0].removeEventListener("doubletap",v.recenterPlot)}function p(a,h,c){h=f;"pinchstart"===a.type?(h=b.getTouchedAxis(a.detail.touches[0].pageX,a.detail.touches[0].pageY),a=b.getTouchedAxis(a.detail.touches[1].pageX,
a.detail.touches[1].pageY),a=h.length===a.length&&h.toString()===a.toString()?h:void 0):a="panstart"===a.type?b.getTouchedAxis(a.detail.touches[0].pageX,a.detail.touches[0].pageY):"pinchend"===a.type?b.getTouchedAxis(a.detail.touches[0].pageX,a.detail.touches[0].pageY):h.touchedAxis;f.touchedAxis=a;f.navigationConstraint=f.touchedAxis&&0!==f.touchedAxis.length?"axisConstrained":"unconstrained"}var e={zoomEnable:!1,prevDistance:null,prevTapTime:0,prevPanPosition:{x:0,y:0},prevTapPosition:{x:0,y:0}},
f={prevTouchedAxis:"none",currentTouchedAxis:"none",touchedAxis:null,navigationConstraint:"unconstrained",initialState:null},u=c.pan.interactive&&"manual"===c.pan.touchMode,x="smartLock"===c.pan.touchMode,w=c.pan.interactive&&(x||"smart"===c.pan.touchMode),m,k,v;m={start:function(a){p(a,"pan",e);y(a,"pan",e,f);w&&(a=n(a,"pan"),f.initialState=b.navigationState(a.x,a.y))},drag:function(a){p(a,"pan",e);w?(a=n(a,"pan"),b.smartPan({x:f.initialState.startPageX-a.x,y:f.initialState.startPageY-a.y},f.initialState,
f.touchedAxis,!1,x)):u&&(b.pan({left:-r(a,"pan",e).x,top:-r(a,"pan",e).y,axes:f.touchedAxis}),z(a,"pan",e,f))},end:function(a){p(a,"pan",e);w&&b.smartPan.end();e.zoomEnable&&1===a.detail.touches.length&&updateprevPanPosition(a,"pan",e,f)}};var l;k={start:function(a){l&&(clearTimeout(l),l=null);p(a,"pinch",e);e.prevDistance=t(a);y(a,"pinch",e,f)},drag:function(a){l||(l=setTimeout(function(){p(a,"pinch",e);b.pan({left:-r(a,"pinch",e).x,top:-r(a,"pinch",e).y,axes:f.touchedAxis});z(a,"pinch",e,f);var h=
t(a);if(e.zoomEnable||Math.abs(h-e.prevDistance)>A){var h=f,c=b.offset(),d={left:0,top:0},g=t(a)/e.prevDistance,k=t(a);d.left=n(a,"pinch").x-c.left;d.top=n(a,"pinch").y-c.top;b.zoom({center:d,amount:g,axes:h.touchedAxis});e.prevDistance=k;e.zoomEnable=!0}l=null},1E3/60))},end:function(a){l&&(clearTimeout(l),l=null);p(a,"pinch",e);e.prevDistance=null}};v={recenterPlot:function(a){if(a&&a.detail&&"touchstart"===a.detail.type){var c=f,d=b.getTouchedAxis(a.detail.firstTouch.x,a.detail.firstTouch.y);void 0!==
d[0]&&(c.prevTouchedAxis=d[0].direction);d=b.getTouchedAxis(a.detail.secondTouch.x,a.detail.secondTouch.y);void 0!==d[0]&&(c.touchedAxis=d,c.currentTouchedAxis=d[0].direction);c.touchedAxis&&0!==c.touchedAxis.length||(c.touchedAxis=null,c.prevTouchedAxis="none",c.currentTouchedAxis="none");if("x"===c.currentTouchedAxis&&"x"===c.prevTouchedAxis||"y"===c.currentTouchedAxis&&"y"===c.prevTouchedAxis||"none"===c.currentTouchedAxis&&"none"===c.prevTouchedAxis)b.recenter({axes:c.touchedAxis}),a=c.touchedAxis?
new q.Event("re-center",{detail:{axisTouched:c.touchedAxis}}):new q.Event("re-center",{detail:a}),b.getPlaceholder().trigger(a)}}};if(!0===c.pan.enableTouch||!0===c.zoom.enableTouch)b.hooks.bindEvents.push(d),b.hooks.shutdown.push(g)}function y(b,c,d,g){c=n(b,c);switch(g.navigationConstraint){case "unconstrained":g.touchedAxis=null;d.prevTapPosition={x:d.prevPanPosition.x,y:d.prevPanPosition.y};d.prevPanPosition={x:c.x,y:c.y};break;case "axisConstrained":b=g.touchedAxis[0].direction,g.currentTouchedAxis=
b,d.prevTapPosition[b]=d.prevPanPosition[b],d.prevPanPosition[b]=c[b]}}function t(b){var c=b.detail.touches[0],d=b.detail.touches[1];b=c.pageX;var c=c.pageY,g=d.pageX,d=d.pageY;return Math.sqrt((b-g)*(b-g)+(c-d)*(c-d))}function z(b,c,d,g){b=n(b,c);switch(g.navigationConstraint){case "unconstrained":d.prevPanPosition.x=b.x;d.prevPanPosition.y=b.y;break;case "axisConstrained":d.prevPanPosition[g.currentTouchedAxis]=b[g.currentTouchedAxis]}}function r(b,c,d){b=n(b,c);return{x:b.x-d.prevPanPosition.x,
y:b.y-d.prevPanPosition.y}}function n(b,c){return"pinch"===c?{x:(b.detail.touches[0].pageX+b.detail.touches[1].pageX)/2,y:(b.detail.touches[0].pageY+b.detail.touches[1].pageY)/2}:{x:b.detail.touches[0].pageX,y:b.detail.touches[0].pageY}}var A=q.plot.uiConstants.ZOOM_DISTANCE_MARGIN;q.plot.plugins.push({init:function(b){b.hooks.processOptions.push(u)},options:{zoom:{enableTouch:!1},pan:{enableTouch:!1,touchMode:"manual"},recenter:{enableTouch:!0}},name:"navigateTouch",version:"0.3"})})(jQuery);
© 2015 - 2025 Weber Informatics LLC | Privacy Policy