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

d3-brush

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-brush - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

6

build/d3-brush.js

@@ -7,3 +7,3 @@ (function (global, factory) {

var version = "0.1.2";
var version = "0.1.3";

@@ -232,5 +232,5 @@ function constant(x) {

args = arguments,
state = that.__brush,
selection = dim.input(typeof selection === "function" ? selection.apply(that, args) : selection, state.extent),
emit = emitter(that, args).beforestart(),
state = that.__brush;
emit = emitter(that, args).beforestart();

@@ -237,0 +237,0 @@ d3Transition.interrupt(that);

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

!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_brush=t.d3_brush||{},t.d3_dispatch,t.d3_drag,t.d3_interpolate,t.d3_selection,t.d3_transition)}(this,function(t,e,n,r,s,i){"use strict";function a(t){return function(){return t}}function u(t,e,n){this.target=t,this.type=e,this.selection=n}function o(){s.event.stopImmediatePropagation()}function l(){s.event.preventDefault(),s.event.stopImmediatePropagation()}function c(t){return{type:t}}function h(){return!s.event.button}function f(){var t=this.ownerSVGElement;return[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]}function p(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function d(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}function v(t){var e=t.__brush;return e?e.dim.output(e.selection):null}function m(){return w(z)}function y(){return w(A)}function b(){return w(q)}function w(t){function v(e){var n=e.property("__brush",g).selectAll(".overlay").data([c("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",E.overlay).merge(n).each(function(){var t=p(this).extent;s.select(this).attr("x",t[0][0]).attr("y",t[0][1]).attr("width",t[1][0]-t[0][0]).attr("height",t[1][1]-t[0][1])}),e.selectAll(".selection").data([c("selection")]).enter().append("rect").attr("class","selection").attr("cursor",E.selection).attr("fill","rgba(0,0,0,0.15)");var r=e.selectAll(".handle").data(t.handles,function(t){return t.type});r.exit().remove(),r.enter().append("rect").attr("class",function(t){return"handle handle--"+t.type}).attr("cursor",function(t){return E[t.type]}),e.each(m).attr("fill","none").attr("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush touchstart.brush",w)}function m(){var t=s.select(this),e=p(this).selection;e?(t.selectAll(".selection").style("display",null).attr("x",e[0][0]).attr("y",e[0][1]).attr("width",e[1][0]-e[0][0]).attr("height",e[1][1]-e[0][1]),t.selectAll(".handle").style("display",null).attr("x",function(t){return"e"===t.type[t.type.length-1]?e[1][0]-P/2:e[0][0]-P/2}).attr("y",function(t){return"s"===t.type[0]?e[1][1]-P/2:e[0][1]-P/2}).attr("width",function(t){return"n"===t.type||"s"===t.type?e[1][0]-e[0][0]+P:P}).attr("height",function(t){return"e"===t.type||"w"===t.type?e[1][1]-e[0][1]+P:P})):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function y(t,e){return t.__brush.emitter||new b(t,e)}function b(t,e){this.that=t,this.args=e,this.state=t.__brush,this.active=0}function w(){function e(){N=s.mouse(X),G=!0,l(),r()}function r(){var t;switch(P=N[0]-Z[0],j=N[1]-Z[1],B){case x:case _:F&&(P=Math.max(Q-h,Math.min(U-w,P)),f=h+P,g=w+P),H&&(j=Math.max(R-v,Math.min(W-C,j)),b=v+j,I=C+j);break;case M:0>F?(P=Math.max(Q-h,Math.min(U-h,P)),f=h+P,g=w):F>0&&(P=Math.max(Q-w,Math.min(U-w,P)),f=h,g=w+P),0>H?(j=Math.max(R-v,Math.min(W-v,j)),b=v+j,I=C):H>0&&(j=Math.max(R-C,Math.min(W-C,j)),b=v,I=C+j);break;case k:F&&(f=Math.max(Q,Math.min(U,h-P*F)),g=Math.max(Q,Math.min(U,w+P*F))),H&&(b=Math.max(R,Math.min(W,v-j*H)),I=Math.max(R,Math.min(W,C+j*H)))}f>g&&(F*=-1,t=h,h=w,w=t,t=f,f=g,g=t,Y in K&&et.attr("cursor",E[Y=K[Y]])),b>I&&(H*=-1,t=v,v=C,C=t,t=b,b=I,I=t,Y in S&&et.attr("cursor",E[Y=S[Y]])),O[0][0]===f&&O[0][1]===b&&O[1][0]===g&&O[1][1]===I||(O[0][0]=f,O[0][1]=b,O[1][0]=g,O[1][1]=I,m.call(X),$.brush())}function a(){if(o(),s.event.touches){if(s.event.touches.length)return;q&&clearTimeout(q),q=setTimeout(function(){q=null},500),tt.on("touchmove.brush touchend.brush touchcancel.brush",null)}else n.dragEnable(s.event.view,G),nt.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);tt.attr("pointer-events","all"),et.attr("cursor",E.overlay),d(O)&&(J.selection=null,m.call(X)),$.end()}function u(){switch(s.event.keyCode){case 18:B===M&&(F&&(w=g-P*F,h=f+P*F),H&&(C=I-j*H,v=b+j*H),B=k,r());break;case 32:B!==M&&B!==k||(0>F?w=g-P:F>0&&(h=f-P),0>H?C=I-j:H>0&&(v=b-j),B=x,et.attr("cursor",E.selection),r());break;default:return}l()}function c(){switch(s.event.keyCode){case 18:B===k&&(0>F?w=g:F>0&&(h=f),0>H?C=I:H>0&&(v=b),B=M,r());break;case 32:B===x&&(s.event.altKey?(F&&(w=g-P*F,h=f+P*F),H&&(C=I-j*H,v=b+j*H),B=k):(0>F?w=g:F>0&&(h=f),0>H?C=I:H>0&&(v=b),B=M),et.attr("cursor",E[Y]),r());break;default:return}l()}if(s.event.touches){if(s.event.changedTouches.length<s.event.touches.length)return l()}else if(q)return;if(D.apply(this,arguments)){var h,f,v,b,w,g,C,I,P,j,G,N,X=this,Y=s.event.target.__data__.type,B="selection"===(s.event.metaKey?Y="overlay":Y)?_:s.event.altKey?k:M,F=t===A?null:T[Y],H=t===z?null:V[Y],J=p(X),L=J.extent,O=J.selection,Q=L[0][0],R=L[0][1],U=L[1][0],W=L[1][1],Z=s.mouse(X),$=y(X,arguments).beforestart();"overlay"===Y?J.selection=O=[[h=t===A?Q:Z[0],v=t===z?R:Z[1]],[w=t===A?U:h,C=t===z?W:v]]:(h=O[0][0],v=O[0][1],w=O[1][0],C=O[1][1]),f=h,b=v,g=w,I=C;var tt=s.select(X).attr("pointer-events","none"),et=tt.selectAll(".overlay").attr("cursor",E[Y]);if(s.event.touches)tt.on("touchmove.brush",e,!0).on("touchend.brush touchcancel.brush",a,!0);else{var nt=s.select(s.event.view).on("keydown.brush",u,!0).on("keyup.brush",c,!0).on("mousemove.brush",e,!0).on("mouseup.brush",a,!0);n.dragDisable(s.event.view)}o(),i.interrupt(X),m.call(X),$.start()}}function g(){var e=this.__brush||{selection:null};return e.extent=C.apply(this,arguments),e.dim=t,e}var q,C=f,D=h,I=e.dispatch(v,"start","brush","end"),P=6;return v.move=function(e,n){e.selection?e.on("start.brush",function(){y(this,arguments).beforestart().start()}).on("interrupt.brush end.brush",function(){y(this,arguments).end()}).tween("brush",function(){function e(t){i.selection=1===t&&d(o)?null:l(t),m.call(s),a.brush()}var s=this,i=s.__brush,a=y(s,arguments),u=i.selection,o=t.input("function"==typeof n?n.apply(this,arguments):n,i.extent),l=r.interpolate(u,o);return u&&o?e:e(1)}):e.each(function(){var e=this,n=arguments,r=t.input("function"==typeof r?r.apply(e,n):r,a.extent),s=y(e,n).beforestart(),a=e.__brush;i.interrupt(e),a.selection=d(r)?null:r,m.call(e),s.start().brush().end()})},b.prototype={beforestart:function(){return 1===++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(){return this.starting&&(this.starting=!1,this.emit("start")),this},brush:function(){return this.emit("brush"),this},end:function(){return 0===--this.active&&(delete this.state.emitter,this.emit("end")),this},emit:function(e){s.customEvent(new u(v,e,t.output(this.state.selection)),I.apply,I,[e,this.that,this.args])}},v.extent=function(t){return arguments.length?(C="function"==typeof t?t:a([[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]]),v):C},v.filter=function(t){return arguments.length?(D="function"==typeof t?t:a(!!t),v):D},v.handleSize=function(t){return arguments.length?(P=+t,v):P},v.on=function(){var t=I.on.apply(I,arguments);return t===I?v:t},v}var g="0.1.2",_={name:"drag"},x={name:"space"},M={name:"handle"},k={name:"center"},z={name:"x",handles:["e","w"].map(c),input:function(t,e){return t&&[[t[0],e[0][1]],[t[1],e[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},A={name:"y",handles:["n","s"].map(c),input:function(t,e){return t&&[[e[0][0],t[0]],[e[1][0],t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},q={name:"xy",handles:["n","e","s","w","nw","ne","se","sw"].map(c),input:function(t){return t},output:function(t){return t}},E={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},K={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},S={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},T={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},V={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};t.version=g,t.brush=b,t.brushX=m,t.brushY=y,t.brushSelection=v});
!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_brush=t.d3_brush||{},t.d3_dispatch,t.d3_drag,t.d3_interpolate,t.d3_selection,t.d3_transition)}(this,function(t,e,n,r,s,i){"use strict";function a(t){return function(){return t}}function u(t,e,n){this.target=t,this.type=e,this.selection=n}function o(){s.event.stopImmediatePropagation()}function l(){s.event.preventDefault(),s.event.stopImmediatePropagation()}function c(t){return{type:t}}function h(){return!s.event.button}function f(){var t=this.ownerSVGElement;return[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]}function p(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function d(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}function v(t){var e=t.__brush;return e?e.dim.output(e.selection):null}function m(){return w(z)}function y(){return w(A)}function b(){return w(q)}function w(t){function v(e){var n=e.property("__brush",g).selectAll(".overlay").data([c("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",E.overlay).merge(n).each(function(){var t=p(this).extent;s.select(this).attr("x",t[0][0]).attr("y",t[0][1]).attr("width",t[1][0]-t[0][0]).attr("height",t[1][1]-t[0][1])}),e.selectAll(".selection").data([c("selection")]).enter().append("rect").attr("class","selection").attr("cursor",E.selection).attr("fill","rgba(0,0,0,0.15)");var r=e.selectAll(".handle").data(t.handles,function(t){return t.type});r.exit().remove(),r.enter().append("rect").attr("class",function(t){return"handle handle--"+t.type}).attr("cursor",function(t){return E[t.type]}),e.each(m).attr("fill","none").attr("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush touchstart.brush",w)}function m(){var t=s.select(this),e=p(this).selection;e?(t.selectAll(".selection").style("display",null).attr("x",e[0][0]).attr("y",e[0][1]).attr("width",e[1][0]-e[0][0]).attr("height",e[1][1]-e[0][1]),t.selectAll(".handle").style("display",null).attr("x",function(t){return"e"===t.type[t.type.length-1]?e[1][0]-P/2:e[0][0]-P/2}).attr("y",function(t){return"s"===t.type[0]?e[1][1]-P/2:e[0][1]-P/2}).attr("width",function(t){return"n"===t.type||"s"===t.type?e[1][0]-e[0][0]+P:P}).attr("height",function(t){return"e"===t.type||"w"===t.type?e[1][1]-e[0][1]+P:P})):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function y(t,e){return t.__brush.emitter||new b(t,e)}function b(t,e){this.that=t,this.args=e,this.state=t.__brush,this.active=0}function w(){function e(){N=s.mouse(X),G=!0,l(),r()}function r(){var t;switch(P=N[0]-Z[0],j=N[1]-Z[1],B){case x:case _:F&&(P=Math.max(Q-h,Math.min(U-w,P)),f=h+P,g=w+P),H&&(j=Math.max(R-v,Math.min(W-C,j)),b=v+j,I=C+j);break;case M:0>F?(P=Math.max(Q-h,Math.min(U-h,P)),f=h+P,g=w):F>0&&(P=Math.max(Q-w,Math.min(U-w,P)),f=h,g=w+P),0>H?(j=Math.max(R-v,Math.min(W-v,j)),b=v+j,I=C):H>0&&(j=Math.max(R-C,Math.min(W-C,j)),b=v,I=C+j);break;case k:F&&(f=Math.max(Q,Math.min(U,h-P*F)),g=Math.max(Q,Math.min(U,w+P*F))),H&&(b=Math.max(R,Math.min(W,v-j*H)),I=Math.max(R,Math.min(W,C+j*H)))}f>g&&(F*=-1,t=h,h=w,w=t,t=f,f=g,g=t,Y in K&&et.attr("cursor",E[Y=K[Y]])),b>I&&(H*=-1,t=v,v=C,C=t,t=b,b=I,I=t,Y in S&&et.attr("cursor",E[Y=S[Y]])),O[0][0]===f&&O[0][1]===b&&O[1][0]===g&&O[1][1]===I||(O[0][0]=f,O[0][1]=b,O[1][0]=g,O[1][1]=I,m.call(X),$.brush())}function a(){if(o(),s.event.touches){if(s.event.touches.length)return;q&&clearTimeout(q),q=setTimeout(function(){q=null},500),tt.on("touchmove.brush touchend.brush touchcancel.brush",null)}else n.dragEnable(s.event.view,G),nt.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);tt.attr("pointer-events","all"),et.attr("cursor",E.overlay),d(O)&&(J.selection=null,m.call(X)),$.end()}function u(){switch(s.event.keyCode){case 18:B===M&&(F&&(w=g-P*F,h=f+P*F),H&&(C=I-j*H,v=b+j*H),B=k,r());break;case 32:B!==M&&B!==k||(0>F?w=g-P:F>0&&(h=f-P),0>H?C=I-j:H>0&&(v=b-j),B=x,et.attr("cursor",E.selection),r());break;default:return}l()}function c(){switch(s.event.keyCode){case 18:B===k&&(0>F?w=g:F>0&&(h=f),0>H?C=I:H>0&&(v=b),B=M,r());break;case 32:B===x&&(s.event.altKey?(F&&(w=g-P*F,h=f+P*F),H&&(C=I-j*H,v=b+j*H),B=k):(0>F?w=g:F>0&&(h=f),0>H?C=I:H>0&&(v=b),B=M),et.attr("cursor",E[Y]),r());break;default:return}l()}if(s.event.touches){if(s.event.changedTouches.length<s.event.touches.length)return l()}else if(q)return;if(D.apply(this,arguments)){var h,f,v,b,w,g,C,I,P,j,G,N,X=this,Y=s.event.target.__data__.type,B="selection"===(s.event.metaKey?Y="overlay":Y)?_:s.event.altKey?k:M,F=t===A?null:T[Y],H=t===z?null:V[Y],J=p(X),L=J.extent,O=J.selection,Q=L[0][0],R=L[0][1],U=L[1][0],W=L[1][1],Z=s.mouse(X),$=y(X,arguments).beforestart();"overlay"===Y?J.selection=O=[[h=t===A?Q:Z[0],v=t===z?R:Z[1]],[w=t===A?U:h,C=t===z?W:v]]:(h=O[0][0],v=O[0][1],w=O[1][0],C=O[1][1]),f=h,b=v,g=w,I=C;var tt=s.select(X).attr("pointer-events","none"),et=tt.selectAll(".overlay").attr("cursor",E[Y]);if(s.event.touches)tt.on("touchmove.brush",e,!0).on("touchend.brush touchcancel.brush",a,!0);else{var nt=s.select(s.event.view).on("keydown.brush",u,!0).on("keyup.brush",c,!0).on("mousemove.brush",e,!0).on("mouseup.brush",a,!0);n.dragDisable(s.event.view)}o(),i.interrupt(X),m.call(X),$.start()}}function g(){var e=this.__brush||{selection:null};return e.extent=C.apply(this,arguments),e.dim=t,e}var q,C=f,D=h,I=e.dispatch(v,"start","brush","end"),P=6;return v.move=function(e,n){e.selection?e.on("start.brush",function(){y(this,arguments).beforestart().start()}).on("interrupt.brush end.brush",function(){y(this,arguments).end()}).tween("brush",function(){function e(t){i.selection=1===t&&d(o)?null:l(t),m.call(s),a.brush()}var s=this,i=s.__brush,a=y(s,arguments),u=i.selection,o=t.input("function"==typeof n?n.apply(this,arguments):n,i.extent),l=r.interpolate(u,o);return u&&o?e:e(1)}):e.each(function(){var e=this,n=arguments,r=e.__brush,s=t.input("function"==typeof s?s.apply(e,n):s,r.extent),a=y(e,n).beforestart();i.interrupt(e),r.selection=d(s)?null:s,m.call(e),a.start().brush().end()})},b.prototype={beforestart:function(){return 1===++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(){return this.starting&&(this.starting=!1,this.emit("start")),this},brush:function(){return this.emit("brush"),this},end:function(){return 0===--this.active&&(delete this.state.emitter,this.emit("end")),this},emit:function(e){s.customEvent(new u(v,e,t.output(this.state.selection)),I.apply,I,[e,this.that,this.args])}},v.extent=function(t){return arguments.length?(C="function"==typeof t?t:a([[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]]),v):C},v.filter=function(t){return arguments.length?(D="function"==typeof t?t:a(!!t),v):D},v.handleSize=function(t){return arguments.length?(P=+t,v):P},v.on=function(){var t=I.on.apply(I,arguments);return t===I?v:t},v}var g="0.1.3",_={name:"drag"},x={name:"space"},M={name:"handle"},k={name:"center"},z={name:"x",handles:["e","w"].map(c),input:function(t,e){return t&&[[t[0],e[0][1]],[t[1],e[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},A={name:"y",handles:["n","s"].map(c),input:function(t,e){return t&&[[e[0][0],t[0]],[e[1][0],t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},q={name:"xy",handles:["n","e","s","w","nw","ne","se","sw"].map(c),input:function(t){return t},output:function(t){return t}},E={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},K={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},S={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},T={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},V={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};t.version=g,t.brush=b,t.brushX=m,t.brushY=y,t.brushSelection=v});
export var name = "d3-brush";
export var version = "0.1.2";
export var version = "0.1.3";
export var description = "Select a one- or two-dimensional region using the mouse or touch.";

@@ -4,0 +4,0 @@ export var keywords = ["d3","brush","interaction"];

{
"name": "d3-brush",
"version": "0.1.2",
"version": "0.1.3",
"description": "Select a one- or two-dimensional region using the mouse or touch.",

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

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

args = arguments,
state = that.__brush,
selection = dim.input(typeof selection === "function" ? selection.apply(that, args) : selection, state.extent),
emit = emitter(that, args).beforestart(),
state = that.__brush;
emit = emitter(that, args).beforestart();

@@ -217,0 +217,0 @@ interrupt(that);

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