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

d3-drag

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-drag - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

18

build/d3-drag.js

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

// https://d3js.org/d3-drag/ Version 1.0.4. Copyright 2017 Mike Bostock.
// https://d3js.org/d3-drag/ Version 1.1.0. Copyright 2017 Mike Bostock.
(function (global, factory) {

@@ -87,4 +87,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-dispatch'), require('d3-selection')) :

active = 0,
mousedownx,
mousedowny,
mousemoving,
touchending;
touchending,
clickDistance2 = 0;

@@ -108,2 +111,4 @@ function drag(selection) {

mousemoving = false;
mousedownx = d3Selection.event.clientX;
mousedowny = d3Selection.event.clientY;
gesture("start");

@@ -114,3 +119,6 @@ }

noevent();
mousemoving = true;
if (!mousemoving) {
var dx = d3Selection.event.clientX - mousedownx, dy = d3Selection.event.clientY - mousedowny;
mousemoving = dx * dx + dy * dy > clickDistance2;
}
gestures.mouse("drag");

@@ -205,2 +213,6 @@ }

drag.clickDistance = function(_) {
return arguments.length ? (clickDistance2 = (_ = +_) * _, drag) : Math.sqrt(clickDistance2);
};
return drag;

@@ -207,0 +219,0 @@ };

4

build/d3-drag.min.js

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

// https://d3js.org/d3-drag/ Version 1.0.4. Copyright 2017 Mike Bostock.
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-dispatch"),require("d3-selection")):"function"==typeof define&&define.amd?define(["exports","d3-dispatch","d3-selection"],t):t(e.d3=e.d3||{},e.d3,e.d3)}(this,function(e,t,n){"use strict";function o(){n.event.stopImmediatePropagation()}function r(e,t){var o=e.document.documentElement,r=n.select(e).on("dragstart.drag",null);t&&(r.on("click.drag",a,!0),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in o?r.on("selectstart.drag",null):(o.style.MozUserSelect=o.__noselect,delete o.__noselect)}function i(e,t,n,o,r,i,u,c,s,a){this.target=e,this.type=t,this.subject=n,this.identifier=o,this.active=r,this.x=i,this.y=u,this.dx=c,this.dy=s,this._=a}function u(){return!n.event.button}function c(){return this.parentNode}function s(e){return null==e?{x:n.event.x,y:n.event.y}:e}var a=function(){n.event.preventDefault(),n.event.stopImmediatePropagation()},d=function(e){var t=e.document.documentElement,o=n.select(e).on("dragstart.drag",a,!0);"onselectstart"in t?o.on("selectstart.drag",a,!0):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")},l=function(e){return function(){return e}};i.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};var f=function(){function e(e){e.on("mousedown.drag",f).on("touchstart.drag",g).on("touchmove.drag",v).on("touchend.drag touchcancel.drag",m).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(){if(!_&&w.apply(this,arguments)){var e=y("mouse",x.apply(this,arguments),n.mouse,this,arguments);e&&(n.select(n.event.view).on("mousemove.drag",h,!0).on("mouseup.drag",p,!0),d(n.event.view),o(),b=!1,e("start"))}}function h(){a(),b=!0,j.mouse("drag")}function p(){n.select(n.event.view).on("mousemove.drag mouseup.drag",null),r(n.event.view,b),a(),j.mouse("end")}function g(){if(w.apply(this,arguments)){var e,t,r=n.event.changedTouches,i=x.apply(this,arguments),u=r.length;for(e=0;e<u;++e)(t=y(r[e].identifier,i,n.touch,this,arguments))&&(o(),t("start"))}}function v(){var e,t,o=n.event.changedTouches,r=o.length;for(e=0;e<r;++e)(t=j[o[e].identifier])&&(a(),t("drag"))}function m(){var e,t,r=n.event.changedTouches,i=r.length;for(_&&clearTimeout(_),_=setTimeout(function(){_=null},500),e=0;e<i;++e)(t=j[r[e].identifier])&&(o(),t("end"))}function y(t,o,r,u,c){var s,a,d,l=r(o,t),f=E.copy();if(n.customEvent(new i(e,"beforestart",s,t,k,l[0],l[1],0,0,f),function(){return null!=(n.event.subject=s=T.apply(u,c))&&(a=s.x-l[0]||0,d=s.y-l[1]||0,!0)}))return function h(p){var g,v=l;switch(p){case"start":j[t]=h,g=k++;break;case"end":delete j[t],--k;case"drag":l=r(o,t),g=k}n.customEvent(new i(e,p,s,t,g,l[0]+a,l[1]+d,l[0]-v[0],l[1]-v[1],f),f.apply,f,[p,u,c])}}var b,_,w=u,x=c,T=s,j={},E=t.dispatch("start","drag","end"),k=0;return e.filter=function(t){return arguments.length?(w="function"==typeof t?t:l(!!t),e):w},e.container=function(t){return arguments.length?(x="function"==typeof t?t:l(t),e):x},e.subject=function(t){return arguments.length?(T="function"==typeof t?t:l(t),e):T},e.on=function(){var t=E.on.apply(E,arguments);return t===E?e:t},e};e.drag=f,e.dragDisable=d,e.dragEnable=r,Object.defineProperty(e,"__esModule",{value:!0})});
// https://d3js.org/d3-drag/ Version 1.1.0. Copyright 2017 Mike Bostock.
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-dispatch"),require("d3-selection")):"function"==typeof define&&define.amd?define(["exports","d3-dispatch","d3-selection"],t):t(e.d3=e.d3||{},e.d3,e.d3)}(this,function(e,t,n){"use strict";function o(){n.event.stopImmediatePropagation()}function i(e,t){var o=e.document.documentElement,i=n.select(e).on("dragstart.drag",null);t&&(i.on("click.drag",a,!0),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in o?i.on("selectstart.drag",null):(o.style.MozUserSelect=o.__noselect,delete o.__noselect)}function r(e,t,n,o,i,r,c,u,s,a){this.target=e,this.type=t,this.subject=n,this.identifier=o,this.active=i,this.x=r,this.y=c,this.dx=u,this.dy=s,this._=a}function c(){return!n.event.button}function u(){return this.parentNode}function s(e){return null==e?{x:n.event.x,y:n.event.y}:e}var a=function(){n.event.preventDefault(),n.event.stopImmediatePropagation()},l=function(e){var t=e.document.documentElement,o=n.select(e).on("dragstart.drag",a,!0);"onselectstart"in t?o.on("selectstart.drag",a,!0):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")},d=function(e){return function(){return e}};r.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};var f=function(){function e(e){e.on("mousedown.drag",f).on("touchstart.drag",p).on("touchmove.drag",g).on("touchend.drag touchcancel.drag",m).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(){if(!x&&T.apply(this,arguments)){var e=y("mouse",j.apply(this,arguments),n.mouse,this,arguments);e&&(n.select(n.event.view).on("mousemove.drag",h,!0).on("mouseup.drag",v,!0),l(n.event.view),o(),w=!1,b=n.event.clientX,_=n.event.clientY,e("start"))}}function h(){if(a(),!w){var e=n.event.clientX-b,t=n.event.clientY-_;w=e*e+t*t>z}E.mouse("drag")}function v(){n.select(n.event.view).on("mousemove.drag mouseup.drag",null),i(n.event.view,w),a(),E.mouse("end")}function p(){if(T.apply(this,arguments)){var e,t,i=n.event.changedTouches,r=j.apply(this,arguments),c=i.length;for(e=0;e<c;++e)(t=y(i[e].identifier,r,n.touch,this,arguments))&&(o(),t("start"))}}function g(){var e,t,o=n.event.changedTouches,i=o.length;for(e=0;e<i;++e)(t=E[o[e].identifier])&&(a(),t("drag"))}function m(){var e,t,i=n.event.changedTouches,r=i.length;for(x&&clearTimeout(x),x=setTimeout(function(){x=null},500),e=0;e<r;++e)(t=E[i[e].identifier])&&(o(),t("end"))}function y(t,o,i,c,u){var s,a,l,d=i(o,t),f=M.copy();if(n.customEvent(new r(e,"beforestart",s,t,q,d[0],d[1],0,0,f),function(){return null!=(n.event.subject=s=k.apply(c,u))&&(a=s.x-d[0]||0,l=s.y-d[1]||0,!0)}))return function h(v){var p,g=d;switch(v){case"start":E[t]=h,p=q++;break;case"end":delete E[t],--q;case"drag":d=i(o,t),p=q}n.customEvent(new r(e,v,s,t,p,d[0]+a,d[1]+l,d[0]-g[0],d[1]-g[1],f),f.apply,f,[v,c,u])}}var b,_,w,x,T=c,j=u,k=s,E={},M=t.dispatch("start","drag","end"),q=0,z=0;return e.filter=function(t){return arguments.length?(T="function"==typeof t?t:d(!!t),e):T},e.container=function(t){return arguments.length?(j="function"==typeof t?t:d(t),e):j},e.subject=function(t){return arguments.length?(k="function"==typeof t?t:d(t),e):k},e.on=function(){var t=M.on.apply(M,arguments);return t===M?e:t},e.clickDistance=function(t){return arguments.length?(z=(t=+t)*t,e):Math.sqrt(z)},e};e.drag=f,e.dragDisable=l,e.dragEnable=i,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "d3-drag",
"version": "1.0.4",
"version": "1.1.0",
"description": "Drag and drop SVG, HTML or Canvas using mouse or touch input.",

@@ -37,3 +37,3 @@ "keywords": [

"eslint": "3",
"package-preamble": "0.0",
"package-preamble": "0.1",
"rollup": "0.41",

@@ -40,0 +40,0 @@ "tape": "4",

@@ -59,3 +59,3 @@ # d3-drag

<br>² Only applies during an active, mouse-based gesture; see [#9](https://github.com/d3/d3-drag/issues/9).
<br>³ Only applies immediately after a non-empty, mouse-based gesture.
<br>³ Only applies immediately after some mouse-based gestures; see [*drag*.clickDistance](#drag_clickDistance).
<br>⁴ Necessary to allow [click emulation](https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW7) on touch input; see [#9](https://github.com/d3/d3-drag/issues/9).

@@ -161,2 +161,6 @@ <br>⁵ Ignored if within 500ms of a touch gesture ending; assumes [click emulation](https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW7).

<a href="#drag_clickDistance" name="drag_clickDistance">#</a> <i>drag</i>.<b>clickDistance</b>([<i>distance</i>]) [<>](https://github.com/d3/d3-drag/blob/master/src/drag.js#L387 "Source")
If *distance* is specified, sets the maximum distance that the mouse can move between mousedown and mouseup that will trigger a subsequent click event. If at any point between mousedown and mouseup the mouse is greater than or equal to *distance* from its position on mousedown, the click event follwing mouseup will be suppressed. If *distance* is not specified, returns the current distance threshold, which defaults to zero. The distance threshold is measured in client coordinates ([*event*.clientX](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientX) and [*event*.clientY](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientY)).
<a href="#drag_on" name="drag_on">#</a> <i>drag</i>.<b>on</b>(<i>typenames</i>, [<i>listener</i>]) [<>](https://github.com/d3/d3-drag/blob/master/src/drag.js#L138 "Source")

@@ -163,0 +167,0 @@

@@ -28,4 +28,7 @@ import {dispatch} from "d3-dispatch";

active = 0,
mousedownx,
mousedowny,
mousemoving,
touchending;
touchending,
clickDistance2 = 0;

@@ -49,2 +52,4 @@ function drag(selection) {

mousemoving = false;
mousedownx = event.clientX;
mousedowny = event.clientY;
gesture("start");

@@ -55,3 +60,6 @@ }

noevent();
mousemoving = true;
if (!mousemoving) {
var dx = event.clientX - mousedownx, dy = event.clientY - mousedowny;
mousemoving = dx * dx + dy * dy > clickDistance2;
}
gestures.mouse("drag");

@@ -146,3 +154,7 @@ }

drag.clickDistance = function(_) {
return arguments.length ? (clickDistance2 = (_ = +_) * _, drag) : Math.sqrt(clickDistance2);
};
return drag;
}
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