Comparing version 1.1.0 to 1.1.1
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-brush/ v1.1.0 Copyright 2019 Mike Bostock | ||
// https://d3js.org/d3-brush/ v1.1.1 Copyright 2019 Mike Bostock | ||
(function (global, factory) { | ||
@@ -139,3 +139,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-dispatch'), require('d3-drag'), require('d3-interpolate'), require('d3-selection'), require('d3-transition')) : | ||
function defaultTouchable() { | ||
return "ontouchstart" in this; | ||
return navigator.maxTouchPoints || ("ontouchstart" in this); | ||
} | ||
@@ -338,2 +338,6 @@ | ||
function pointer(target) { | ||
return d3Selection.clientPoint(target, d3Selection.event.touches ? d3Selection.event.touches[0] : d3Selection.event); | ||
} | ||
function started() { | ||
@@ -362,3 +366,3 @@ if (d3Selection.event.touches) { if (d3Selection.event.changedTouches.length < d3Selection.event.touches.length) return noevent(); } | ||
lockY, | ||
point0 = d3Selection.mouse(that), | ||
point0 = pointer(that), | ||
point = point0, | ||
@@ -368,2 +372,3 @@ emit = emitter(that, arguments, true).beforestart(); | ||
if (type === "overlay") { | ||
if (selection) moving = true; | ||
state.selection = selection = [ | ||
@@ -411,3 +416,3 @@ [w0 = dim === Y ? W : point0[0], n0 = dim === X ? N : point0[1]], | ||
function moved() { | ||
var point1 = d3Selection.mouse(that); | ||
var point1 = pointer(that); | ||
if (shifting && !lockX && !lockY) { | ||
@@ -414,0 +419,0 @@ if (Math.abs(point1[0] - point[0]) > Math.abs(point1[1] - point[1])) lockY = true; |
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-brush/ v1.1.0 Copyright 2019 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=t||self).d3=t.d3||{},t.d3,t.d3,t.d3,t.d3,t.d3)}(this,function(t,e,n,r,s,i){"use strict";function u(t){return function(){return t}}function a(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()}var c={name:"drag"},h={name:"space"},f={name:"handle"},d={name:"center"};function p(t){return[+t[0],+t[1]]}function v(t){return[p(t[0]),p(t[1])]}var m={name:"x",handles:["w","e"].map(k),input:function(t,e){return null==t?null:[[+t[0],e[0][1]],[+t[1],e[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},y={name:"y",handles:["n","s"].map(k),input:function(t,e){return null==t?null:[[e[0][0],+t[0]],[e[1][0],+t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},b={name:"xy",handles:["nw","n","ne","w","e","sw","s","se"].map(k),input:function(t){return null==t?null:v(t)},output:function(t){return t}},w={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"},g={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},x={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},M={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},_={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function k(t){return{type:t}}function z(){return!s.event.button}function A(){var t=this.ownerSVGElement||this;return 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]]}function q(){return"ontouchstart"in this}function E(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function K(t){var p,b=A,K=z,V=q,P=!0,S=e.dispatch(j,"start","brush","end"),T=6;function j(e){var n=e.property("__brush",O).selectAll(".overlay").data([k("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",w.overlay).merge(n).each(function(){var t=E(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([k("selection")]).enter().append("rect").attr("class","selection").attr("cursor",w.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");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 w[t.type]}),e.each(B).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",I).filter(V).on("touchstart.brush",I).on("touchmove.brush",G).on("touchend.brush touchcancel.brush",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function B(){var t=s.select(this),e=E(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]-T/2:e[0][0]-T/2}).attr("y",function(t){return"s"===t.type[0]?e[1][1]-T/2:e[0][1]-T/2}).attr("width",function(t){return"n"===t.type||"s"===t.type?e[1][0]-e[0][0]+T:T}).attr("height",function(t){return"e"===t.type||"w"===t.type?e[1][1]-e[0][1]+T:T})):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function C(t,e,n){return!n&&t.__brush.emitter||new D(t,e)}function D(t,e){this.that=t,this.args=e,this.state=t.__brush,this.active=0}function I(){if(s.event.touches){if(s.event.changedTouches.length<s.event.touches.length)return l()}else if(p)return;if(K.apply(this,arguments)){var e,r,u,a,v,b,k,z,A,q,V,S=this,T=s.event.target.__data__.type,j="selection"===(P&&s.event.metaKey?T="overlay":T)?c:P&&s.event.altKey?d:f,D=t===y?null:M[T],I=t===m?null:_[T],G=E(S),N=G.extent,O=G.selection,X=N[0][0],Y=N[0][1],F=N[1][0],H=N[1][1],J=0,L=0,Q=D&&I&&P&&s.event.shiftKey,R=s.mouse(S),U=R,W=C(S,arguments,!0).beforestart();"overlay"===T?G.selection=O=[[e=t===y?X:R[0],u=t===m?Y:R[1]],[v=t===y?F:e,k=t===m?H:u]]:(e=O[0][0],u=O[0][1],v=O[1][0],k=O[1][1]),r=e,a=u,b=v,z=k;var Z=s.select(S).attr("pointer-events","none"),$=Z.selectAll(".overlay").attr("cursor",w[T]);if(s.event.touches)W.moved=et,W.ended=rt;else{var tt=s.select(s.event.view).on("mousemove.brush",et,!0).on("mouseup.brush",rt,!0);P&&tt.on("keydown.brush",function(){switch(s.event.keyCode){case 16:Q=D&&I;break;case 18:j===f&&(D&&(v=b-J*D,e=r+J*D),I&&(k=z-L*I,u=a+L*I),j=d,nt());break;case 32:j!==f&&j!==d||(D<0?v=b-J:D>0&&(e=r-J),I<0?k=z-L:I>0&&(u=a-L),j=h,$.attr("cursor",w.selection),nt());break;default:return}l()},!0).on("keyup.brush",function(){switch(s.event.keyCode){case 16:Q&&(q=V=Q=!1,nt());break;case 18:j===d&&(D<0?v=b:D>0&&(e=r),I<0?k=z:I>0&&(u=a),j=f,nt());break;case 32:j===h&&(s.event.altKey?(D&&(v=b-J*D,e=r+J*D),I&&(k=z-L*I,u=a+L*I),j=d):(D<0?v=b:D>0&&(e=r),I<0?k=z:I>0&&(u=a),j=f),$.attr("cursor",w[T]),nt());break;default:return}l()},!0),n.dragDisable(s.event.view)}o(),i.interrupt(S),B.call(S),W.start()}function et(){var t=s.mouse(S);!Q||q||V||(Math.abs(t[0]-U[0])>Math.abs(t[1]-U[1])?V=!0:q=!0),U=t,A=!0,l(),nt()}function nt(){var t;switch(J=U[0]-R[0],L=U[1]-R[1],j){case h:case c:D&&(J=Math.max(X-e,Math.min(F-v,J)),r=e+J,b=v+J),I&&(L=Math.max(Y-u,Math.min(H-k,L)),a=u+L,z=k+L);break;case f:D<0?(J=Math.max(X-e,Math.min(F-e,J)),r=e+J,b=v):D>0&&(J=Math.max(X-v,Math.min(F-v,J)),r=e,b=v+J),I<0?(L=Math.max(Y-u,Math.min(H-u,L)),a=u+L,z=k):I>0&&(L=Math.max(Y-k,Math.min(H-k,L)),a=u,z=k+L);break;case d:D&&(r=Math.max(X,Math.min(F,e-J*D)),b=Math.max(X,Math.min(F,v+J*D))),I&&(a=Math.max(Y,Math.min(H,u-L*I)),z=Math.max(Y,Math.min(H,k+L*I)))}b<r&&(D*=-1,t=e,e=v,v=t,t=r,r=b,b=t,T in g&&$.attr("cursor",w[T=g[T]])),z<a&&(I*=-1,t=u,u=k,k=t,t=a,a=z,z=t,T in x&&$.attr("cursor",w[T=x[T]])),G.selection&&(O=G.selection),q&&(r=O[0][0],b=O[1][0]),V&&(a=O[0][1],z=O[1][1]),O[0][0]===r&&O[0][1]===a&&O[1][0]===b&&O[1][1]===z||(G.selection=[[r,a],[b,z]],B.call(S),W.brush())}function rt(){if(o(),s.event.touches){if(s.event.touches.length)return;p&&clearTimeout(p),p=setTimeout(function(){p=null},500)}else n.dragEnable(s.event.view,A),tt.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);Z.attr("pointer-events","all"),$.attr("cursor",w.overlay),G.selection&&(O=G.selection),function(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}(O)&&(G.selection=null,B.call(S)),W.end()}}function G(){C(this,arguments).moved()}function N(){C(this,arguments).ended()}function O(){var e=this.__brush||{selection:null};return e.extent=v(b.apply(this,arguments)),e.dim=t,e}return j.move=function(e,n){e.selection?e.on("start.brush",function(){C(this,arguments).beforestart().start()}).on("interrupt.brush end.brush",function(){C(this,arguments).end()}).tween("brush",function(){var e=this,s=e.__brush,i=C(e,arguments),u=s.selection,a=t.input("function"==typeof n?n.apply(this,arguments):n,s.extent),o=r.interpolate(u,a);function l(t){s.selection=1===t&&null===a?null:o(t),B.call(e),i.brush()}return null!==u&&null!==a?l:l(1)}):e.each(function(){var e=this,r=arguments,s=e.__brush,u=t.input("function"==typeof n?n.apply(e,r):n,s.extent),a=C(e,r).beforestart();i.interrupt(e),s.selection=null===u?null:u,B.call(e),a.start().brush().end()})},j.clear=function(t){j.move(t,null)},D.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.emit("brush"),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 a(j,e,t.output(this.state.selection)),S.apply,S,[e,this.that,this.args])}},j.extent=function(t){return arguments.length?(b="function"==typeof t?t:u(v(t)),j):b},j.filter=function(t){return arguments.length?(K="function"==typeof t?t:u(!!t),j):K},j.handleSize=function(t){return arguments.length?(T=+t,j):T},j.keyModifiers=function(t){return arguments.length?(P=!!t,j):P},j.on=function(){var t=S.on.apply(S,arguments);return t===S?j:t},j}t.brush=function(){return K(b)},t.brushSelection=function(t){var e=t.__brush;return e?e.dim.output(e.selection):null},t.brushX=function(){return K(m)},t.brushY=function(){return K(y)},Object.defineProperty(t,"__esModule",{value:!0})}); | ||
// https://d3js.org/d3-brush/ v1.1.1 Copyright 2019 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=t||self).d3=t.d3||{},t.d3,t.d3,t.d3,t.d3,t.d3)}(this,function(t,e,n,r,i,s){"use strict";function u(t){return function(){return t}}function a(t,e,n){this.target=t,this.type=e,this.selection=n}function o(){i.event.stopImmediatePropagation()}function l(){i.event.preventDefault(),i.event.stopImmediatePropagation()}var c={name:"drag"},h={name:"space"},f={name:"handle"},d={name:"center"};function p(t){return[+t[0],+t[1]]}function v(t){return[p(t[0]),p(t[1])]}var y={name:"x",handles:["w","e"].map(k),input:function(t,e){return null==t?null:[[+t[0],e[0][1]],[+t[1],e[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},m={name:"y",handles:["n","s"].map(k),input:function(t,e){return null==t?null:[[e[0][0],+t[0]],[e[1][0],+t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},b={name:"xy",handles:["nw","n","ne","w","e","sw","s","se"].map(k),input:function(t){return null==t?null:v(t)},output:function(t){return t}},w={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"},g={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},x={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},M={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},_={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function k(t){return{type:t}}function z(){return!i.event.button}function A(){var t=this.ownerSVGElement||this;return 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]]}function q(){return navigator.maxTouchPoints||"ontouchstart"in this}function P(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function E(t){var p,b=A,E=z,K=q,T=!0,V=e.dispatch(j,"start","brush","end"),S=6;function j(e){var n=e.property("__brush",X).selectAll(".overlay").data([k("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",w.overlay).merge(n).each(function(){var t=P(this).extent;i.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([k("selection")]).enter().append("rect").attr("class","selection").attr("cursor",w.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");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 w[t.type]}),e.each(B).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",G).filter(K).on("touchstart.brush",G).on("touchmove.brush",N).on("touchend.brush touchcancel.brush",O).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function B(){var t=i.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]-S/2:e[0][0]-S/2}).attr("y",function(t){return"s"===t.type[0]?e[1][1]-S/2:e[0][1]-S/2}).attr("width",function(t){return"n"===t.type||"s"===t.type?e[1][0]-e[0][0]+S:S}).attr("height",function(t){return"e"===t.type||"w"===t.type?e[1][1]-e[0][1]+S:S})):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function C(t,e,n){return!n&&t.__brush.emitter||new D(t,e)}function D(t,e){this.that=t,this.args=e,this.state=t.__brush,this.active=0}function I(t){return i.clientPoint(t,i.event.touches?i.event.touches[0]:i.event)}function G(){if(i.event.touches){if(i.event.changedTouches.length<i.event.touches.length)return l()}else if(p)return;if(E.apply(this,arguments)){var e,r,u,a,v,b,k,z,A,q,K,V=this,S=i.event.target.__data__.type,j="selection"===(T&&i.event.metaKey?S="overlay":S)?c:T&&i.event.altKey?d:f,D=t===m?null:M[S],G=t===y?null:_[S],N=P(V),O=N.extent,X=N.selection,Y=O[0][0],F=O[0][1],H=O[1][0],J=O[1][1],L=0,Q=0,R=D&&G&&T&&i.event.shiftKey,U=I(V),W=U,Z=C(V,arguments,!0).beforestart();"overlay"===S?(X&&(A=!0),N.selection=X=[[e=t===m?Y:U[0],u=t===y?F:U[1]],[v=t===m?H:e,k=t===y?J:u]]):(e=X[0][0],u=X[0][1],v=X[1][0],k=X[1][1]),r=e,a=u,b=v,z=k;var $=i.select(V).attr("pointer-events","none"),tt=$.selectAll(".overlay").attr("cursor",w[S]);if(i.event.touches)Z.moved=nt,Z.ended=it;else{var et=i.select(i.event.view).on("mousemove.brush",nt,!0).on("mouseup.brush",it,!0);T&&et.on("keydown.brush",function(){switch(i.event.keyCode){case 16:R=D&&G;break;case 18:j===f&&(D&&(v=b-L*D,e=r+L*D),G&&(k=z-Q*G,u=a+Q*G),j=d,rt());break;case 32:j!==f&&j!==d||(D<0?v=b-L:D>0&&(e=r-L),G<0?k=z-Q:G>0&&(u=a-Q),j=h,tt.attr("cursor",w.selection),rt());break;default:return}l()},!0).on("keyup.brush",function(){switch(i.event.keyCode){case 16:R&&(q=K=R=!1,rt());break;case 18:j===d&&(D<0?v=b:D>0&&(e=r),G<0?k=z:G>0&&(u=a),j=f,rt());break;case 32:j===h&&(i.event.altKey?(D&&(v=b-L*D,e=r+L*D),G&&(k=z-Q*G,u=a+Q*G),j=d):(D<0?v=b:D>0&&(e=r),G<0?k=z:G>0&&(u=a),j=f),tt.attr("cursor",w[S]),rt());break;default:return}l()},!0),n.dragDisable(i.event.view)}o(),s.interrupt(V),B.call(V),Z.start()}function nt(){var t=I(V);!R||q||K||(Math.abs(t[0]-W[0])>Math.abs(t[1]-W[1])?K=!0:q=!0),W=t,A=!0,l(),rt()}function rt(){var t;switch(L=W[0]-U[0],Q=W[1]-U[1],j){case h:case c:D&&(L=Math.max(Y-e,Math.min(H-v,L)),r=e+L,b=v+L),G&&(Q=Math.max(F-u,Math.min(J-k,Q)),a=u+Q,z=k+Q);break;case f:D<0?(L=Math.max(Y-e,Math.min(H-e,L)),r=e+L,b=v):D>0&&(L=Math.max(Y-v,Math.min(H-v,L)),r=e,b=v+L),G<0?(Q=Math.max(F-u,Math.min(J-u,Q)),a=u+Q,z=k):G>0&&(Q=Math.max(F-k,Math.min(J-k,Q)),a=u,z=k+Q);break;case d:D&&(r=Math.max(Y,Math.min(H,e-L*D)),b=Math.max(Y,Math.min(H,v+L*D))),G&&(a=Math.max(F,Math.min(J,u-Q*G)),z=Math.max(F,Math.min(J,k+Q*G)))}b<r&&(D*=-1,t=e,e=v,v=t,t=r,r=b,b=t,S in g&&tt.attr("cursor",w[S=g[S]])),z<a&&(G*=-1,t=u,u=k,k=t,t=a,a=z,z=t,S in x&&tt.attr("cursor",w[S=x[S]])),N.selection&&(X=N.selection),q&&(r=X[0][0],b=X[1][0]),K&&(a=X[0][1],z=X[1][1]),X[0][0]===r&&X[0][1]===a&&X[1][0]===b&&X[1][1]===z||(N.selection=[[r,a],[b,z]],B.call(V),Z.brush())}function it(){if(o(),i.event.touches){if(i.event.touches.length)return;p&&clearTimeout(p),p=setTimeout(function(){p=null},500)}else n.dragEnable(i.event.view,A),et.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);$.attr("pointer-events","all"),tt.attr("cursor",w.overlay),N.selection&&(X=N.selection),function(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}(X)&&(N.selection=null,B.call(V)),Z.end()}}function N(){C(this,arguments).moved()}function O(){C(this,arguments).ended()}function X(){var e=this.__brush||{selection:null};return e.extent=v(b.apply(this,arguments)),e.dim=t,e}return j.move=function(e,n){e.selection?e.on("start.brush",function(){C(this,arguments).beforestart().start()}).on("interrupt.brush end.brush",function(){C(this,arguments).end()}).tween("brush",function(){var e=this,i=e.__brush,s=C(e,arguments),u=i.selection,a=t.input("function"==typeof n?n.apply(this,arguments):n,i.extent),o=r.interpolate(u,a);function l(t){i.selection=1===t&&null===a?null:o(t),B.call(e),s.brush()}return null!==u&&null!==a?l:l(1)}):e.each(function(){var e=this,r=arguments,i=e.__brush,u=t.input("function"==typeof n?n.apply(e,r):n,i.extent),a=C(e,r).beforestart();s.interrupt(e),i.selection=null===u?null:u,B.call(e),a.start().brush().end()})},j.clear=function(t){j.move(t,null)},D.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.emit("brush"),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){i.customEvent(new a(j,e,t.output(this.state.selection)),V.apply,V,[e,this.that,this.args])}},j.extent=function(t){return arguments.length?(b="function"==typeof t?t:u(v(t)),j):b},j.filter=function(t){return arguments.length?(E="function"==typeof t?t:u(!!t),j):E},j.handleSize=function(t){return arguments.length?(S=+t,j):S},j.keyModifiers=function(t){return arguments.length?(T=!!t,j):T},j.on=function(){var t=V.on.apply(V,arguments);return t===V?j:t},j}t.brush=function(){return E(b)},t.brushSelection=function(t){var e=t.__brush;return e?e.dim.output(e.selection):null},t.brushX=function(){return E(y)},t.brushY=function(){return E(m)},Object.defineProperty(t,"__esModule",{value:!0})}); |
{ | ||
"name": "d3-brush", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Select a one- or two-dimensional region using the mouse or touch.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -132,3 +132,3 @@ # d3-brush | ||
function touchable() { | ||
return "ontouchstart" in this; | ||
return navigator.maxTouchPoints || ("ontouchstart" in this); | ||
} | ||
@@ -135,0 +135,0 @@ ``` |
import {dispatch} from "d3-dispatch"; | ||
import {dragDisable, dragEnable} from "d3-drag"; | ||
import {interpolate} from "d3-interpolate"; | ||
import {customEvent, event, mouse, select} from "d3-selection"; | ||
import {customEvent, event, clientPoint, select} from "d3-selection"; | ||
import {interrupt} from "d3-transition"; | ||
@@ -120,3 +120,3 @@ import constant from "./constant.js"; | ||
function defaultTouchable() { | ||
return "ontouchstart" in this; | ||
return navigator.maxTouchPoints || ("ontouchstart" in this); | ||
} | ||
@@ -319,2 +319,6 @@ | ||
function pointer(target) { | ||
return clientPoint(target, event.touches ? event.touches[0] : event); | ||
} | ||
function started() { | ||
@@ -343,3 +347,3 @@ if (event.touches) { if (event.changedTouches.length < event.touches.length) return noevent(); } | ||
lockY, | ||
point0 = mouse(that), | ||
point0 = pointer(that), | ||
point = point0, | ||
@@ -349,2 +353,3 @@ emit = emitter(that, arguments, true).beforestart(); | ||
if (type === "overlay") { | ||
if (selection) moving = true; | ||
state.selection = selection = [ | ||
@@ -392,3 +397,3 @@ [w0 = dim === Y ? W : point0[0], n0 = dim === X ? N : point0[1]], | ||
function moved() { | ||
var point1 = mouse(that); | ||
var point1 = pointer(that); | ||
if (shifting && !lockX && !lockY) { | ||
@@ -395,0 +400,0 @@ if (Math.abs(point1[0] - point[0]) > Math.abs(point1[1] - point[1])) lockY = true; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62387
1105