pages/the_ascension_tree/js/panzoom.min.js

6 lines
9.2 KiB
JavaScript
Raw Normal View History

/**
* Panzoom for panning and zooming elements using CSS transforms
* Copyright Timmy Willison and other contributors
* https://github.com/timmywil/panzoom/blob/master/MIT-License.txt
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Panzoom=e()}(this,function(){"use strict";var N=function(){return(N=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function L(t,e){for(var n=t.length;n--;)if(t[n].pointerId===e.pointerId)return n;return-1}function I(t,e){var n;if(e.touches)for(var o=n=0,r=e.touches;o<r.length;o++){var a=r[o];a.pointerId=n++,I(t,a)}else-1<(n=L(t,e))&&t.splice(n,1),t.push(e)}function W(t){for(var e,n=(t=t.slice(0)).pop();e=t.pop();)n={clientX:(e.clientX-n.clientX)/2+n.clientX,clientY:(e.clientY-n.clientY)/2+n.clientY};return n}function Z(t){if(t.length<2)return 0;var e=t[0],n=t[1];return Math.sqrt(Math.pow(Math.abs(n.clientX-e.clientX),2)+Math.pow(Math.abs(n.clientY-e.clientY),2))}"undefined"!=typeof window&&(window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(t,e){e=e||{bubbles:!1,cancelable:!1,detail:null};var n=document.createEvent("CustomEvent");return n.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),n}));var q={down:"mousedown",move:"mousemove",up:"mouseup mouseleave"};function B(t,e,n,o){q[t].split(" ").forEach(function(t){e.addEventListener(t,n,o)})}function D(t,e,n){q[t].split(" ").forEach(function(t){e.removeEventListener(t,n)})}"undefined"!=typeof window&&("function"==typeof window.PointerEvent?q={down:"pointerdown",move:"pointermove",up:"pointerup pointerleave pointercancel"}:"function"==typeof window.TouchEvent&&(q={down:"touchstart",move:"touchmove",up:"touchend touchcancel"}));var a,c="undefined"!=typeof document&&!!document.documentMode;var i=["webkit","moz","ms"],l={};function F(t){if(l[t])return l[t];var e=a=a||document.createElement("div").style;if(t in e)return l[t]=t;for(var n=t[0].toUpperCase()+t.slice(1),o=i.length;o--;){var r=""+i[o]+n;if(r in e)return l[t]=r}}function r(t,e){return parseFloat(e[F(t)])||0}function p(t,e,n){void 0===n&&(n=window.getComputedStyle(t));var o="border"===e?"Width":"";return{left:r(e+"Left"+o,n),right:r(e+"Right"+o,n),top:r(e+"Top"+o,n),bottom:r(e+"Bottom"+o,n)}}function R(t,e,n){t.style[F(e)]=n}function j(t){var e=t.parentNode,n=window.getComputedStyle(t),o=window.getComputedStyle(e),r=t.getBoundingClientRect(),a=e.getBoundingClientRect();return{elem:{style:n,width:r.width,height:r.height,top:r.top,bottom:r.bottom,left:r.left,right:r.right,margin:p(t,"margin",n),border:p(t,"border",n)},parent:{style:o,width:a.width,height:a.height,top:a.top,bottom:a.bottom,left:a.left,right:a.right,padding:p(e,"padding",o),border:p(e,"border",o)}}}var V=/^http:[\w\.\/]+svg$/;var G={animate:!1,canvas:!1,cursor:"move",disablePan:!1,disableZoom:!1,disableXAxis:!1,disableYAxis:!1,duration:200,easing:"ease-in-out",exclude:[],excludeClass:"panzoom-exclude",handleStartEvent:function(t){t.preventDefault(),t.stopPropagation()},maxScale:4,minScale:.125,overflow:"hidden",panOnlyWhenZoomed:!1,relative:!1,setTransform:function(t,e,n){var o,r=e.x,a=e.y,i=e.scale,l=e.isSVG;R(t,"transform","scale("+i+") translate("+r+"px, "+a+"px)"),l&&c&&(o=window.getComputedStyle(t).getPropertyValue("transform"),t.setAttribute("transform",o))},startX:0,startY:0,startScale:1,step:.3,touchAction:"none"};function t(g,y){if(!g)throw new Error("Panzoom requires an element as an argument");if(1!==g.nodeType)throw new Error("Panzoom requires an element with a nodeType of 1");if(e=(t=g).ownerDocument,n=t.parentNode,!(e&&n&&9===e.nodeType&&1===n.nodeType&&e.documentElement.contains(n)))throw new Error("Panzoom should be called on elements that have been attached to the DOM");var t,e,n;y=N(N({},G),y);var o,p=(o=g,V.test(o.namespaceURI)&&"svg"!==o.nodeName.toLowerCase()),r=g.parentNode;r.style.overflow=y.overflow,r.style.userSelect="none",r.style.touchAction=y.touchAction,(y.canvas?r:g).style.cursor=y.cursor,