backy/docs/themes/hugo-theme-relearn/static/js/d3/d3-zoom.min.js

3 lines
9.8 KiB
JavaScript
Raw Normal View History

// https://d3js.org/d3-zoom/ v3.0.0 Copyright 2010-2021 Mike Bostock
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3-dispatch"),require("d3-drag"),require("d3-interpolate"),require("d3-selection"),require("d3-transition")):"function"==typeof define&&define.amd?define(["exports","d3-dispatch","d3-drag","d3-interpolate","d3-selection","d3-transition"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).d3=t.d3||{},t.d3,t.d3,t.d3,t.d3,t.d3)}(this,(function(t,e,n,o,i,r){"use strict";var u=t=>()=>t;function s(t,{sourceEvent:e,target:n,transform:o,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:i}})}function h(t,e,n){this.k=t,this.x=e,this.y=n}h.prototype={constructor:h,scale:function(t){return 1===t?this:new h(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new h(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var a=new h(1,0,0);function c(t){for(;!t.__zoom;)if(!(t=t.parentNode))return a;return t.__zoom}function l(t){t.stopImmediatePropagation()}function f(t){t.preventDefault(),t.stopImmediatePropagation()}function p(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function m(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function v(){return this.__zoom||a}function d(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function y(){return navigator.maxTouchPoints||"ontouchstart"in this}function g(t,e,n){var o=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],r=t.invertY(e[0][1])-n[0][1],u=t.invertY(e[1][1])-n[1][1];return t.translate(i>o?(o+i)/2:Math.min(0,o)||Math.max(0,i),u>r?(r+u)/2:Math.min(0,r)||Math.max(0,u))}c.prototype=h.prototype,t.ZoomTransform=h,t.zoom=function(){var t,c,z,_=p,x=m,k=g,w=d,b=y,T=[0,1/0],M=[[-1/0,-1/0],[1/0,1/0]],E=250,Y=o.interpolateZoom,X=e.dispatch("start","zoom","end"),q=500,D=0,P=10;function V(t){t.property("__zoom",v).on("wheel.zoom",O,{passive:!1}).on("mousedown.zoom",Z).on("dblclick.zoom",A).filter(b).on("touchstart.zoom",H).on("touchmove.zoom",N).on("touchend.zoom touchcancel.zoom",W).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function B(t,e){return(e=Math.max(T[0],Math.min(T[1],e)))===t.k?t:new h(e,t.x,t.y)}function j(t,e,n){var o=e[0]-n[0]*t.k,i=e[1]-n[1]*t.k;return o===t.x&&i===t.y?t:new h(t.k,o,i)}function I(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function K(t,e,n,o){t.on("start.zoom",(function(){S(this,arguments).event(o).start()})).on("interrupt.zoom end.zoom",(function(){S(this,arguments).event(o).end()})).tween("zoom",(function(){var t=this,i=arguments,r=S(t,i).event(o),u=x.apply(t,i),s=null==n?I(u):"function"==typeof n?n.apply(t,i):n,a=Math.max(u[1][0]-u[0][0],u[1][1]-u[0][1]),c=t.__zoom,l="function"==typeof e?e.apply(t,i):e,f=Y(c.invert(s).concat(a/c.k),l.invert(s).concat(a/l.k));return function(t){if(1===t)t=l;else{var e=f(t),n=a/e[2];t=new h(n,s[0]-e[0]*n,s[1]-e[1]*n)}r.zoom(null,t)}}))}function S(t,e,n){return!n&&t.__zooming||new G(t,e)}function G(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=x.apply(t,e),this.taps=0}function O(t,...e){if(_.apply(this,arguments)){var n=S(this,e).event(t),o=this.__zoom,u=Math.max(T[0],Math.min(T[1],o