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.1.1 to 1.2.0

9

build/d3-drag.js

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

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

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

function touchable() {
function defaultTouchable() {
return "ontouchstart" in this;

@@ -89,2 +89,3 @@ }

subject = defaultSubject,
touchable = defaultTouchable,
gestures = {},

@@ -213,2 +214,6 @@ listeners = d3Dispatch.dispatch("start", "drag", "end"),

drag.touchable = function(_) {
return arguments.length ? (touchable = typeof _ === "function" ? _ : constant(_), drag) : touchable;
};
drag.on = function() {

@@ -215,0 +220,0 @@ var value = listeners.on.apply(listeners, arguments);

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

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

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

"scripts": {
"pretest": "rm -rf build && mkdir build && rollup -c --banner \"$(preamble)\" -g d3-dispatch:d3,d3-selection:d3 -o build/d3-drag.js",
"pretest": "rm -rf build && mkdir build && rollup -c --banner \"$(preamble)\"",
"test": "tape 'test/**/*-test.js' && eslint index.js src",
"prepublish": "npm run test && uglifyjs -b beautify=false,preamble=\"'$(preamble)'\" build/d3-drag.js -c -m -o build/d3-drag.min.js",
"prepublishOnly": "npm run test && uglifyjs -b beautify=false,preamble=\"'$(preamble)'\" build/d3-drag.js -c -m -o build/d3-drag.min.js",
"postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../d3-drag/build/d3-drag.js d3-drag.v1.js && cp ../d3-drag/build/d3-drag.min.js d3-drag.v1.min.js && git add d3-drag.v1.js d3-drag.v1.min.js && git commit -m \"d3-drag ${npm_package_version}\" && git push && cd - && zip -j build/d3-drag.zip -- LICENSE README.md build/d3-drag.js build/d3-drag.min.js"

@@ -39,3 +39,3 @@ },

"package-preamble": "0.1",
"rollup": "0.45",
"rollup": "0.50",
"tape": "4",

@@ -42,0 +42,0 @@ "uglify-js": "3"

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

<a href="#_drag" name="_drag">#</a> <i>drag</i>(<i>selection</i>) [<>](https://github.com/d3/d3-drag/blob/master/src/drag.js#L31 "Source")
<a href="#_drag" name="_drag">#</a> <i>drag</i>(<i>selection</i>) [<>](https://github.com/d3/d3-drag/blob/master/src/drag.js#L39 "Source")

@@ -84,3 +84,3 @@ Applies this drag behavior to the specified [*selection*](https://github.com/d3/d3-selection). This function is typically not invoked directly, and is instead invoked via [*selection*.call](https://github.com/d3/d3-selection#selection_call). For example, to instantiate a drag behavior and apply it to a selection:

<a href="#drag_container" name="drag_container">#</a> <i>drag</i>.<b>container</b>([<i>container</i>]) [<>](https://github.com/d3/d3-drag/blob/master/src/drag.js#L31 "Source")
<a href="#drag_container" name="drag_container">#</a> <i>drag</i>.<b>container</b>([<i>container</i>]) [<>](https://github.com/d3/d3-drag/blob/master/src/drag.js#L145 "Source")

@@ -107,3 +107,3 @@ If *container* is specified, sets the container accessor to the specified object or function and returns the drag behavior. If *container* is not specified, returns the current container accessor, which defaults to:

<a href="#drag_filter" href="drag_filter">#</a> <i>drag</i>.<b>filter</b>([<i>filter</i>]) [<>](https://github.com/d3/d3-drag/blob/master/src/drag.js#L126 "Source")
<a href="#drag_filter" name="drag_filter">#</a> <i>drag</i>.<b>filter</b>([<i>filter</i>]) [<>](https://github.com/d3/d3-drag/blob/master/src/drag.js#L141 "Source")

@@ -120,4 +120,16 @@ If *filter* is specified, sets the filter to the specified function and returns the drag behavior. If *filter* is not specified, returns the current filter, which defaults to:

<a href="#drag_subject" name="drag_subject">#</a> <i>drag</i>.<b>subject</b>([<i>subject</i>]) [<>](https://github.com/d3/d3-drag/blob/master/src/drag.js#L134 "Source")
<a href="#touchable" name="touchable">#</a> <i>drag</i>.<b>touchable</b>([<i>touchable</i>]) [<>](https://github.com/d3/d3-drag/blob/master/src/drag.js#L153 "Source")
If *touchable* is specified, sets the touch support detector to the specified function and returns the drag behavior. If *touchable* is not specified, returns the current touch support detector, which defaults to:
```js
function touchable() {
return "ontouchstart" in this;
}
```
Touch event listeners are only registered if the detector returns truthy for the corresponding element when the drag behavior is [applied](#_drag). The default detector works well for most browsers that are capable of touch input, but not all; Chrome’s mobile device emulator, for example, fails detection.
<a href="#drag_subject" name="drag_subject">#</a> <i>drag</i>.<b>subject</b>([<i>subject</i>]) [<>](https://github.com/d3/d3-drag/blob/master/src/drag.js#L149 "Source")
If *subject* is specified, sets the subject accessor to the specified object or function and returns the drag behavior. If *subject* is not specified, returns the current subject accessor, which defaults to:

@@ -164,7 +176,7 @@

<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")
<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#L162 "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")
<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#L157 "Source")

@@ -171,0 +183,0 @@ If *listener* is specified, sets the event *listener* for the specified *typenames* and returns the drag behavior. If an event listener was already registered for the same type and name, the existing listener is removed before the new listener is added. If *listener* is null, removes the current event listeners for the specified *typenames*, if any. If *listener* is not specified, returns the first currently-assigned listener matching the specified *typenames*, if any. When a specified event is dispatched, each *listener* will be invoked with the same context and arguments as [*selection*.on](https://github.com/d3/d3-selection#selection_on) listeners: the current datum `d` and index `i`, with the `this` context as the current DOM element.

@@ -0,6 +1,14 @@

const definition = require("./package.json");
const dependencies = Object.keys(definition.dependencies);
export default {
entry: "index",
extend: true,
format: "umd",
moduleName: "d3"
input: "index",
external: dependencies,
output: {
extend: true,
file: `build/${definition.name}.js`,
format: "umd",
globals: dependencies.reduce((p, v) => (p[v] = "d3", p), {}),
name: "d3"
}
};

@@ -21,3 +21,3 @@ import {dispatch} from "d3-dispatch";

function touchable() {
function defaultTouchable() {
return "ontouchstart" in this;

@@ -30,2 +30,3 @@ }

subject = defaultSubject,
touchable = defaultTouchable,
gestures = {},

@@ -154,2 +155,6 @@ listeners = dispatch("start", "drag", "end"),

drag.touchable = function(_) {
return arguments.length ? (touchable = typeof _ === "function" ? _ : constant(_), drag) : touchable;
};
drag.on = function() {

@@ -156,0 +161,0 @@ var value = listeners.on.apply(listeners, arguments);

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