Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-zoom

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-zoom - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

45

build/d3-zoom.js

@@ -1,2 +0,2 @@

// https://d3js.org/d3-zoom/ Version 1.0.1. Copyright 2016 Mike Bostock.
// https://d3js.org/d3-zoom/ Version 1.0.2. Copyright 2016 Mike Bostock.
(function (global, factory) {

@@ -114,9 +114,5 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-dispatch'), require('d3-drag'), require('d3-interpolate'), require('d3-selection'), require('d3-transition')) :

listeners = d3Dispatch.dispatch("start", "zoom", "end"),
mousemoving,
mousePoint,
mouseLocation,
touchstarting,
touchending,
touchDelay = 500,
wheelTimer,
wheelDelay = 150;

@@ -235,2 +231,3 @@

this.active = 0;
this.extent = extent.apply(that, args);
}

@@ -247,3 +244,3 @@

zoom: function(key, transform) {
if (mousePoint && key !== "mouse") mouseLocation = transform.invert(mousePoint);
if (this.mouse && key !== "mouse") this.mouse[1] = transform.invert(this.mouse[0]);
if (this.touch0 && key !== "touch") this.touch0[1] = transform.invert(this.touch0[0]);

@@ -258,3 +255,2 @@ if (this.touch1 && key !== "touch") this.touch1[1] = transform.invert(this.touch1[0]);

gestures.splice(this.index, 1);
mousePoint = mouseLocation = null;
this.index = -1;

@@ -274,12 +270,12 @@ this.emit("end");

t = this.__zoom,
k = Math.max(k0, Math.min(k1, t.k * Math.pow(2, -d3Selection.event.deltaY * (d3Selection.event.deltaMode ? 120 : 1) / 500)));
k = Math.max(k0, Math.min(k1, t.k * Math.pow(2, -d3Selection.event.deltaY * (d3Selection.event.deltaMode ? 120 : 1) / 500))),
p = d3Selection.mouse(this);
// If the mouse is in the same location as before, reuse it.
// If there were recent wheel events, reset the wheel idle timeout.
if (wheelTimer) {
var point = d3Selection.mouse(this);
if (mousePoint[0] !== point[0] || mousePoint[1] !== point[1]) {
mouseLocation = t.invert(mousePoint = point);
if (g.wheel) {
if (g.mouse[0][0] !== p[0] || g.mouse[0][1] !== p[1]) {
g.mouse[1] = t.invert(g.mouse[0] = p);
}
clearTimeout(wheelTimer);
clearTimeout(g.wheel);
}

@@ -292,4 +288,3 @@

else {
g.extent = extent.apply(this, arguments);
mouseLocation = t.invert(mousePoint = d3Selection.mouse(this));
g.mouse = [p, t.invert(p)];
d3Transition.interrupt(this);

@@ -300,7 +295,7 @@ g.start();

noevent();
wheelTimer = setTimeout(wheelidled, wheelDelay);
g.zoom("mouse", constrain(translate(scale(t, k), mousePoint, mouseLocation), g.extent));
g.wheel = setTimeout(wheelidled, wheelDelay);
g.zoom("mouse", constrain(translate(scale(t, k), g.mouse[0], g.mouse[1]), g.extent));
function wheelidled() {
wheelTimer = null;
g.wheel = null;
g.end();

@@ -313,9 +308,8 @@ }

var g = gesture(this, arguments),
v = d3Selection.select(d3Selection.event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true);
v = d3Selection.select(d3Selection.event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true),
p = d3Selection.mouse(this);
d3Drag.dragDisable(d3Selection.event.view);
nopropagation();
mousemoving = false;
g.extent = extent.apply(this, arguments);
mouseLocation = this.__zoom.invert(mousePoint = d3Selection.mouse(this));
g.mouse = [p, this.__zoom.invert(p)];
d3Transition.interrupt(this);

@@ -326,4 +320,4 @@ g.start();

noevent();
mousemoving = true;
g.zoom("mouse", constrain(translate(g.that.__zoom, mousePoint = d3Selection.mouse(g.that), mouseLocation), g.extent));
g.moved = true;
g.zoom("mouse", constrain(translate(g.that.__zoom, g.mouse[0] = d3Selection.mouse(g.that), g.mouse[1]), g.extent));
}

@@ -333,3 +327,3 @@

v.on("mousemove.zoom mouseup.zoom", null);
d3Drag.dragEnable(d3Selection.event.view, mousemoving);
d3Drag.dragEnable(d3Selection.event.view, g.moved);
noevent();

@@ -373,3 +367,2 @@ g.end();

d3Transition.interrupt(this);
g.extent = extent.apply(this, arguments);
g.start();

@@ -376,0 +369,0 @@ }

@@ -1,2 +0,2 @@

// https://d3js.org/d3-zoom/ Version 1.0.1. Copyright 2016 Mike Bostock.
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(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"],n):n(t.d3=t.d3||{},t.d3,t.d3,t.d3,t.d3,t.d3)}(this,function(t,n,e,o,i,r){"use strict";function u(t){return function(){return t}}function h(t,n,e){this.target=t,this.type=n,this.transform=e}function s(t,n,e){this.k=t,this.x=n,this.y=e}function c(t){return t.__zoom||v}function a(){i.event.stopImmediatePropagation()}function f(){i.event.preventDefault(),i.event.stopImmediatePropagation()}function l(){return!i.event.button}function p(){var t,n,e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,t=e.width.baseVal.value,n=e.height.baseVal.value):(t=e.clientWidth,n=e.clientHeight),[[0,0],[t,n]]}function m(){return this.__zoom||v}function d(){function t(t){t.on("wheel.zoom",g).on("mousedown.zoom",k).on("dblclick.zoom",w).on("touchstart.zoom",M).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",b).style("-webkit-tap-highlight-color","rgba(0,0,0,0)").property("__zoom",m)}function c(t,n){return n=Math.max(j,Math.min(B,n)),n===t.k?t:new s(n,t.x,t.y)}function d(t,n,e){var o=n[0]-e[0]*t.k,i=n[1]-e[1]*t.k;return o===t.x&&i===t.y?t:new s(t.k,o,i)}function v(t,n){var e=Math.min(0,t.invertX(n[0][0])-D)||Math.max(0,t.invertX(n[1][0])-G),o=Math.min(0,t.invertY(n[0][1])-H)||Math.max(0,t.invertY(n[1][1])-K);return e||o?t.translate(e,o):t}function y(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function z(t,n,e){t.on("start.zoom",function(){_(this,arguments).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).end()}).tween("zoom",function(){var t=this,i=arguments,r=_(t,i),u=S.apply(t,i),h=e||y(u),c=Math.max(u[1][0]-u[0][0],u[1][1]-u[0][1]),a=t.__zoom,f="function"==typeof n?n.apply(t,i):n,l=o.interpolateZoom(a.invert(h).concat(c/a.k),f.invert(h).concat(c/f.k));return function(t){if(1===t)t=f;else{var n=l(t),e=c/n[2];t=new s(e,h[0]-n[0]*e,h[1]-n[1]*e)}r.zoom(null,t)}})}function _(t,n){for(var e,o=0,i=W.length;o<i;++o)if((e=W[o]).that===t)return e;return new x(t,n)}function x(t,n){this.that=t,this.args=n,this.index=-1,this.active=0}function g(){function t(){I=null,n.end()}if(P.apply(this,arguments)){var n=_(this,arguments),e=this.__zoom,o=Math.max(j,Math.min(B,e.k*Math.pow(2,-i.event.deltaY*(i.event.deltaMode?120:1)/500)));if(I){var u=i.mouse(this);q[0]===u[0]&&q[1]===u[1]||(E=e.invert(q=u)),clearTimeout(I)}else{if(e.k===o)return;n.extent=S.apply(this,arguments),E=e.invert(q=i.mouse(this)),r.interrupt(this),n.start()}f(),I=setTimeout(t,C),n.zoom("mouse",v(d(c(e,o),q,E),n.extent))}}function k(){function t(){f(),Y=!0,o.zoom("mouse",v(d(o.that.__zoom,q=i.mouse(o.that),E),o.extent))}function n(){u.on("mousemove.zoom mouseup.zoom",null),e.dragEnable(i.event.view,Y),f(),o.end()}if(!V&&P.apply(this,arguments)){var o=_(this,arguments),u=i.select(i.event.view).on("mousemove.zoom",t,!0).on("mouseup.zoom",n,!0);e.dragDisable(i.event.view),a(),Y=!1,o.extent=S.apply(this,arguments),E=this.__zoom.invert(q=i.mouse(this)),r.interrupt(this),o.start()}}function w(){if(P.apply(this,arguments)){var n=this.__zoom,e=i.mouse(this),o=n.invert(e),r=n.k*(i.event.shiftKey?.5:2),u=v(d(c(n,r),e,o),S.apply(this,arguments));f(),O>0?i.select(this).transition().duration(O).call(z,u,e):i.select(this).call(t.transform,u)}}function M(){if(P.apply(this,arguments)){var t,n,e,o=_(this,arguments),u=i.event.changedTouches,h=u.length;for(a(),t=0;t<h;++t)n=u[t],e=i.touch(this,u,n.identifier),e=[e,this.__zoom.invert(e),n.identifier],o.touch0?o.touch1||(o.touch1=e):o.touch0=e;return X&&(X=clearTimeout(X),!o.touch1)?(o.end(),w.apply(this,arguments)):void(i.event.touches.length===h&&(X=setTimeout(function(){X=null},A),r.interrupt(this),o.extent=S.apply(this,arguments),o.start()))}}function T(){var t,n,e,o,r=_(this,arguments),u=i.event.changedTouches,h=u.length;for(f(),X&&(X=clearTimeout(X)),t=0;t<h;++t)n=u[t],e=i.touch(this,u,n.identifier),r.touch0&&r.touch0[2]===n.identifier?r.touch0[0]=e:r.touch1&&r.touch1[2]===n.identifier&&(r.touch1[0]=e);if(n=r.that.__zoom,r.touch1){var s=r.touch0[0],a=r.touch0[1],l=r.touch1[0],p=r.touch1[1],m=(m=l[0]-s[0])*m+(m=l[1]-s[1])*m,y=(y=p[0]-a[0])*y+(y=p[1]-a[1])*y;n=c(n,Math.sqrt(m/y)),e=[(s[0]+l[0])/2,(s[1]+l[1])/2],o=[(a[0]+p[0])/2,(a[1]+p[1])/2]}else{if(!r.touch0)return;e=r.touch0[0],o=r.touch0[1]}r.zoom("touch",v(d(n,e,o),r.extent))}function b(){var t,n,e=_(this,arguments),o=i.event.changedTouches,r=o.length;for(a(),V&&clearTimeout(V),V=setTimeout(function(){V=null},A),t=0;t<r;++t)n=o[t],e.touch0&&e.touch0[2]===n.identifier?delete e.touch0:e.touch1&&e.touch1[2]===n.identifier&&delete e.touch1;e.touch1&&!e.touch0&&(e.touch0=e.touch1,delete e.touch1),e.touch0||e.end()}var Y,q,E,X,V,I,P=l,S=p,j=0,B=1/0,D=-B,G=B,H=D,K=G,O=250,W=[],Z=n.dispatch("start","zoom","end"),A=500,C=150;return t.transform=function(t,n){var e=t.selection?t.selection():t;e.property("__zoom",m),t!==e?z(t,n):e.interrupt().each(function(){_(this,arguments).start().zoom(null,"function"==typeof n?n.apply(this,arguments):n).end()})},t.scaleBy=function(n,e){t.scaleTo(n,function(){var t=this.__zoom.k,n="function"==typeof e?e.apply(this,arguments):e;return t*n})},t.scaleTo=function(n,e){t.transform(n,function(){var t=S.apply(this,arguments),n=this.__zoom,o=y(t),i=n.invert(o),r="function"==typeof e?e.apply(this,arguments):e;return v(d(c(n,r),o,i),t)})},t.translateBy=function(n,e,o){t.transform(n,function(){return v(this.__zoom.translate("function"==typeof e?e.apply(this,arguments):e,"function"==typeof o?o.apply(this,arguments):o),S.apply(this,arguments))})},x.prototype={start:function(){return 1===++this.active&&(this.index=W.push(this)-1,this.emit("start")),this},zoom:function(t,n){return q&&"mouse"!==t&&(E=n.invert(q)),this.touch0&&"touch"!==t&&(this.touch0[1]=n.invert(this.touch0[0])),this.touch1&&"touch"!==t&&(this.touch1[1]=n.invert(this.touch1[0])),this.that.__zoom=n,this.emit("zoom"),this},end:function(){return 0===--this.active&&(W.splice(this.index,1),q=E=null,this.index=-1,this.emit("end")),this},emit:function(n){i.customEvent(new h(t,n,this.that.__zoom),Z.apply,Z,[n,this.that,this.args])}},t.filter=function(n){return arguments.length?(P="function"==typeof n?n:u(!!n),t):P},t.extent=function(n){return arguments.length?(S="function"==typeof n?n:u([[+n[0][0],+n[0][1]],[+n[1][0],+n[1][1]]]),t):S},t.scaleExtent=function(n){return arguments.length?(j=+n[0],B=+n[1],t):[j,B]},t.translateExtent=function(n){return arguments.length?(D=+n[0][0],G=+n[1][0],H=+n[0][1],K=+n[1][1],t):[[D,H],[G,K]]},t.duration=function(n){return arguments.length?(O=+n,t):O},t.on=function(){var n=Z.on.apply(Z,arguments);return n===Z?t:n},t}s.prototype={constructor:s,scale:function(t){return 1===t?this:new s(this.k*t,this.x,this.y)},translate:function(t,n){return 0===t&0===n?this:new s(this.k,this.x+this.k*t,this.y+this.k*n)},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 v=new s(1,0,0);c.prototype=s.prototype,t.zoom=d,t.zoomTransform=c,t.zoomIdentity=v,Object.defineProperty(t,"__esModule",{value:!0})});
// https://d3js.org/d3-zoom/ Version 1.0.2. Copyright 2016 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.d3=t.d3||{},t.d3,t.d3,t.d3,t.d3,t.d3)}(this,function(t,e,n,o,i,r){"use strict";function u(t){return function(){return t}}function h(t,e,n){this.target=t,this.type=e,this.transform=n}function s(t,e,n){this.k=t,this.x=e,this.y=n}function c(t){return t.__zoom||v}function a(){i.event.stopImmediatePropagation()}function f(){i.event.preventDefault(),i.event.stopImmediatePropagation()}function m(){return!i.event.button}function l(){var t,e,n=this;return n instanceof SVGElement?(n=n.ownerSVGElement||n,t=n.width.baseVal.value,e=n.height.baseVal.value):(t=n.clientWidth,e=n.clientHeight),[[0,0],[t,e]]}function p(){return this.__zoom||v}function d(){function t(t){t.on("wheel.zoom",x).on("mousedown.zoom",k).on("dblclick.zoom",w).on("touchstart.zoom",M).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",b).style("-webkit-tap-highlight-color","rgba(0,0,0,0)").property("__zoom",p)}function c(t,e){return e=Math.max(V,Math.min(I,e)),e===t.k?t:new s(e,t.x,t.y)}function d(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 s(t.k,o,i)}function v(t,e){var n=Math.min(0,t.invertX(e[0][0])-P)||Math.max(0,t.invertX(e[1][0])-S),o=Math.min(0,t.invertY(e[0][1])-j)||Math.max(0,t.invertY(e[1][1])-B);return n||o?t.translate(n,o):t}function y(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function z(t,e,n){t.on("start.zoom",function(){_(this,arguments).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).end()}).tween("zoom",function(){var t=this,i=arguments,r=_(t,i),u=X.apply(t,i),h=n||y(u),c=Math.max(u[1][0]-u[0][0],u[1][1]-u[0][1]),a=t.__zoom,f="function"==typeof e?e.apply(t,i):e,m=o.interpolateZoom(a.invert(h).concat(c/a.k),f.invert(h).concat(c/f.k));return function(t){if(1===t)t=f;else{var e=m(t),n=c/e[2];t=new s(n,h[0]-e[0]*n,h[1]-e[1]*n)}r.zoom(null,t)}})}function _(t,e){for(var n,o=0,i=G.length;o<i;++o)if((n=G[o]).that===t)return n;return new g(t,e)}function g(t,e){this.that=t,this.args=e,this.index=-1,this.active=0,this.extent=X.apply(t,e)}function x(){function t(){e.wheel=null,e.end()}if(E.apply(this,arguments)){var e=_(this,arguments),n=this.__zoom,o=Math.max(V,Math.min(I,n.k*Math.pow(2,-i.event.deltaY*(i.event.deltaMode?120:1)/500))),u=i.mouse(this);if(e.wheel)e.mouse[0][0]===u[0]&&e.mouse[0][1]===u[1]||(e.mouse[1]=n.invert(e.mouse[0]=u)),clearTimeout(e.wheel);else{if(n.k===o)return;e.mouse=[u,n.invert(u)],r.interrupt(this),e.start()}f(),e.wheel=setTimeout(t,O),e.zoom("mouse",v(d(c(n,o),e.mouse[0],e.mouse[1]),e.extent))}}function k(){function t(){f(),o.moved=!0,o.zoom("mouse",v(d(o.that.__zoom,o.mouse[0]=i.mouse(o.that),o.mouse[1]),o.extent))}function e(){u.on("mousemove.zoom mouseup.zoom",null),n.dragEnable(i.event.view,o.moved),f(),o.end()}if(!q&&E.apply(this,arguments)){var o=_(this,arguments),u=i.select(i.event.view).on("mousemove.zoom",t,!0).on("mouseup.zoom",e,!0),h=i.mouse(this);n.dragDisable(i.event.view),a(),o.mouse=[h,this.__zoom.invert(h)],r.interrupt(this),o.start()}}function w(){if(E.apply(this,arguments)){var e=this.__zoom,n=i.mouse(this),o=e.invert(n),r=e.k*(i.event.shiftKey?.5:2),u=v(d(c(e,r),n,o),X.apply(this,arguments));f(),D>0?i.select(this).transition().duration(D).call(z,u,n):i.select(this).call(t.transform,u)}}function M(){if(E.apply(this,arguments)){var t,e,n,o=_(this,arguments),u=i.event.changedTouches,h=u.length;for(a(),t=0;t<h;++t)e=u[t],n=i.touch(this,u,e.identifier),n=[n,this.__zoom.invert(n),e.identifier],o.touch0?o.touch1||(o.touch1=n):o.touch0=n;return Y&&(Y=clearTimeout(Y),!o.touch1)?(o.end(),w.apply(this,arguments)):void(i.event.touches.length===h&&(Y=setTimeout(function(){Y=null},K),r.interrupt(this),o.start()))}}function T(){var t,e,n,o,r=_(this,arguments),u=i.event.changedTouches,h=u.length;for(f(),Y&&(Y=clearTimeout(Y)),t=0;t<h;++t)e=u[t],n=i.touch(this,u,e.identifier),r.touch0&&r.touch0[2]===e.identifier?r.touch0[0]=n:r.touch1&&r.touch1[2]===e.identifier&&(r.touch1[0]=n);if(e=r.that.__zoom,r.touch1){var s=r.touch0[0],a=r.touch0[1],m=r.touch1[0],l=r.touch1[1],p=(p=m[0]-s[0])*p+(p=m[1]-s[1])*p,y=(y=l[0]-a[0])*y+(y=l[1]-a[1])*y;e=c(e,Math.sqrt(p/y)),n=[(s[0]+m[0])/2,(s[1]+m[1])/2],o=[(a[0]+l[0])/2,(a[1]+l[1])/2]}else{if(!r.touch0)return;n=r.touch0[0],o=r.touch0[1]}r.zoom("touch",v(d(e,n,o),r.extent))}function b(){var t,e,n=_(this,arguments),o=i.event.changedTouches,r=o.length;for(a(),q&&clearTimeout(q),q=setTimeout(function(){q=null},K),t=0;t<r;++t)e=o[t],n.touch0&&n.touch0[2]===e.identifier?delete n.touch0:n.touch1&&n.touch1[2]===e.identifier&&delete n.touch1;n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0||n.end()}var Y,q,E=m,X=l,V=0,I=1/0,P=-I,S=I,j=P,B=S,D=250,G=[],H=e.dispatch("start","zoom","end"),K=500,O=150;return t.transform=function(t,e){var n=t.selection?t.selection():t;n.property("__zoom",p),t!==n?z(t,e):n.interrupt().each(function(){_(this,arguments).start().zoom(null,"function"==typeof e?e.apply(this,arguments):e).end()})},t.scaleBy=function(e,n){t.scaleTo(e,function(){var t=this.__zoom.k,e="function"==typeof n?n.apply(this,arguments):n;return t*e})},t.scaleTo=function(e,n){t.transform(e,function(){var t=X.apply(this,arguments),e=this.__zoom,o=y(t),i=e.invert(o),r="function"==typeof n?n.apply(this,arguments):n;return v(d(c(e,r),o,i),t)})},t.translateBy=function(e,n,o){t.transform(e,function(){return v(this.__zoom.translate("function"==typeof n?n.apply(this,arguments):n,"function"==typeof o?o.apply(this,arguments):o),X.apply(this,arguments))})},g.prototype={start:function(){return 1===++this.active&&(this.index=G.push(this)-1,this.emit("start")),this},zoom:function(t,e){return this.mouse&&"mouse"!==t&&(this.mouse[1]=e.invert(this.mouse[0])),this.touch0&&"touch"!==t&&(this.touch0[1]=e.invert(this.touch0[0])),this.touch1&&"touch"!==t&&(this.touch1[1]=e.invert(this.touch1[0])),this.that.__zoom=e,this.emit("zoom"),this},end:function(){return 0===--this.active&&(G.splice(this.index,1),this.index=-1,this.emit("end")),this},emit:function(e){i.customEvent(new h(t,e,this.that.__zoom),H.apply,H,[e,this.that,this.args])}},t.filter=function(e){return arguments.length?(E="function"==typeof e?e:u(!!e),t):E},t.extent=function(e){return arguments.length?(X="function"==typeof e?e:u([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),t):X},t.scaleExtent=function(e){return arguments.length?(V=+e[0],I=+e[1],t):[V,I]},t.translateExtent=function(e){return arguments.length?(P=+e[0][0],S=+e[1][0],j=+e[0][1],B=+e[1][1],t):[[P,j],[S,B]]},t.duration=function(e){return arguments.length?(D=+e,t):D},t.on=function(){var e=H.on.apply(H,arguments);return e===H?t:e},t}s.prototype={constructor:s,scale:function(t){return 1===t?this:new s(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new s(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 v=new s(1,0,0);c.prototype=s.prototype,t.zoom=d,t.zoomTransform=c,t.zoomIdentity=v,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "d3-zoom",
"version": "1.0.1",
"version": "1.0.2",
"description": "Pan and zoom SVG, HTML or Canvas using mouse or touch input.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -45,9 +45,5 @@ import {dispatch} from "d3-dispatch";

listeners = dispatch("start", "zoom", "end"),
mousemoving,
mousePoint,
mouseLocation,
touchstarting,
touchending,
touchDelay = 500,
wheelTimer,
wheelDelay = 150;

@@ -166,2 +162,3 @@

this.active = 0;
this.extent = extent.apply(that, args);
}

@@ -178,3 +175,3 @@

zoom: function(key, transform) {
if (mousePoint && key !== "mouse") mouseLocation = transform.invert(mousePoint);
if (this.mouse && key !== "mouse") this.mouse[1] = transform.invert(this.mouse[0]);
if (this.touch0 && key !== "touch") this.touch0[1] = transform.invert(this.touch0[0]);

@@ -189,3 +186,2 @@ if (this.touch1 && key !== "touch") this.touch1[1] = transform.invert(this.touch1[0]);

gestures.splice(this.index, 1);
mousePoint = mouseLocation = null;
this.index = -1;

@@ -205,12 +201,12 @@ this.emit("end");

t = this.__zoom,
k = Math.max(k0, Math.min(k1, t.k * Math.pow(2, -event.deltaY * (event.deltaMode ? 120 : 1) / 500)));
k = Math.max(k0, Math.min(k1, t.k * Math.pow(2, -event.deltaY * (event.deltaMode ? 120 : 1) / 500))),
p = mouse(this);
// If the mouse is in the same location as before, reuse it.
// If there were recent wheel events, reset the wheel idle timeout.
if (wheelTimer) {
var point = mouse(this);
if (mousePoint[0] !== point[0] || mousePoint[1] !== point[1]) {
mouseLocation = t.invert(mousePoint = point);
if (g.wheel) {
if (g.mouse[0][0] !== p[0] || g.mouse[0][1] !== p[1]) {
g.mouse[1] = t.invert(g.mouse[0] = p);
}
clearTimeout(wheelTimer);
clearTimeout(g.wheel);
}

@@ -223,4 +219,3 @@

else {
g.extent = extent.apply(this, arguments);
mouseLocation = t.invert(mousePoint = mouse(this));
g.mouse = [p, t.invert(p)];
interrupt(this);

@@ -231,7 +226,7 @@ g.start();

noevent();
wheelTimer = setTimeout(wheelidled, wheelDelay);
g.zoom("mouse", constrain(translate(scale(t, k), mousePoint, mouseLocation), g.extent));
g.wheel = setTimeout(wheelidled, wheelDelay);
g.zoom("mouse", constrain(translate(scale(t, k), g.mouse[0], g.mouse[1]), g.extent));
function wheelidled() {
wheelTimer = null;
g.wheel = null;
g.end();

@@ -244,9 +239,8 @@ }

var g = gesture(this, arguments),
v = select(event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true);
v = select(event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true),
p = mouse(this);
dragDisable(event.view);
nopropagation();
mousemoving = false;
g.extent = extent.apply(this, arguments);
mouseLocation = this.__zoom.invert(mousePoint = mouse(this));
g.mouse = [p, this.__zoom.invert(p)];
interrupt(this);

@@ -257,4 +251,4 @@ g.start();

noevent();
mousemoving = true;
g.zoom("mouse", constrain(translate(g.that.__zoom, mousePoint = mouse(g.that), mouseLocation), g.extent));
g.moved = true;
g.zoom("mouse", constrain(translate(g.that.__zoom, g.mouse[0] = mouse(g.that), g.mouse[1]), g.extent));
}

@@ -264,3 +258,3 @@

v.on("mousemove.zoom mouseup.zoom", null);
dragEnable(event.view, mousemoving);
dragEnable(event.view, g.moved);
noevent();

@@ -304,3 +298,2 @@ g.end();

interrupt(this);
g.extent = extent.apply(this, arguments);
g.start();

@@ -307,0 +300,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc