add hw2
This commit is contained in:
273
node_modules/d3-drag/dist/d3-drag.js
generated
vendored
Normal file
273
node_modules/d3-drag/dist/d3-drag.js
generated
vendored
Normal file
@@ -0,0 +1,273 @@
|
||||
// https://d3js.org/d3-drag/ v3.0.0 Copyright 2010-2021 Mike Bostock
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-dispatch'), require('d3-selection')) :
|
||||
typeof define === 'function' && define.amd ? define(['exports', 'd3-dispatch', 'd3-selection'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {}, global.d3, global.d3));
|
||||
}(this, (function (exports, d3Dispatch, d3Selection) { 'use strict';
|
||||
|
||||
// These are typically used in conjunction with noevent to ensure that we can
|
||||
// preventDefault on the event.
|
||||
const nonpassive = {passive: false};
|
||||
const nonpassivecapture = {capture: true, passive: false};
|
||||
|
||||
function nopropagation(event) {
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
|
||||
function noevent(event) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
|
||||
function nodrag(view) {
|
||||
var root = view.document.documentElement,
|
||||
selection = d3Selection.select(view).on("dragstart.drag", noevent, nonpassivecapture);
|
||||
if ("onselectstart" in root) {
|
||||
selection.on("selectstart.drag", noevent, nonpassivecapture);
|
||||
} else {
|
||||
root.__noselect = root.style.MozUserSelect;
|
||||
root.style.MozUserSelect = "none";
|
||||
}
|
||||
}
|
||||
|
||||
function yesdrag(view, noclick) {
|
||||
var root = view.document.documentElement,
|
||||
selection = d3Selection.select(view).on("dragstart.drag", null);
|
||||
if (noclick) {
|
||||
selection.on("click.drag", noevent, nonpassivecapture);
|
||||
setTimeout(function() { selection.on("click.drag", null); }, 0);
|
||||
}
|
||||
if ("onselectstart" in root) {
|
||||
selection.on("selectstart.drag", null);
|
||||
} else {
|
||||
root.style.MozUserSelect = root.__noselect;
|
||||
delete root.__noselect;
|
||||
}
|
||||
}
|
||||
|
||||
var constant = x => () => x;
|
||||
|
||||
function DragEvent(type, {
|
||||
sourceEvent,
|
||||
subject,
|
||||
target,
|
||||
identifier,
|
||||
active,
|
||||
x, y, dx, dy,
|
||||
dispatch
|
||||
}) {
|
||||
Object.defineProperties(this, {
|
||||
type: {value: type, enumerable: true, configurable: true},
|
||||
sourceEvent: {value: sourceEvent, enumerable: true, configurable: true},
|
||||
subject: {value: subject, enumerable: true, configurable: true},
|
||||
target: {value: target, enumerable: true, configurable: true},
|
||||
identifier: {value: identifier, enumerable: true, configurable: true},
|
||||
active: {value: active, enumerable: true, configurable: true},
|
||||
x: {value: x, enumerable: true, configurable: true},
|
||||
y: {value: y, enumerable: true, configurable: true},
|
||||
dx: {value: dx, enumerable: true, configurable: true},
|
||||
dy: {value: dy, enumerable: true, configurable: true},
|
||||
_: {value: dispatch}
|
||||
});
|
||||
}
|
||||
|
||||
DragEvent.prototype.on = function() {
|
||||
var value = this._.on.apply(this._, arguments);
|
||||
return value === this._ ? this : value;
|
||||
};
|
||||
|
||||
// Ignore right-click, since that should open the context menu.
|
||||
function defaultFilter(event) {
|
||||
return !event.ctrlKey && !event.button;
|
||||
}
|
||||
|
||||
function defaultContainer() {
|
||||
return this.parentNode;
|
||||
}
|
||||
|
||||
function defaultSubject(event, d) {
|
||||
return d == null ? {x: event.x, y: event.y} : d;
|
||||
}
|
||||
|
||||
function defaultTouchable() {
|
||||
return navigator.maxTouchPoints || ("ontouchstart" in this);
|
||||
}
|
||||
|
||||
function drag() {
|
||||
var filter = defaultFilter,
|
||||
container = defaultContainer,
|
||||
subject = defaultSubject,
|
||||
touchable = defaultTouchable,
|
||||
gestures = {},
|
||||
listeners = d3Dispatch.dispatch("start", "drag", "end"),
|
||||
active = 0,
|
||||
mousedownx,
|
||||
mousedowny,
|
||||
mousemoving,
|
||||
touchending,
|
||||
clickDistance2 = 0;
|
||||
|
||||
function drag(selection) {
|
||||
selection
|
||||
.on("mousedown.drag", mousedowned)
|
||||
.filter(touchable)
|
||||
.on("touchstart.drag", touchstarted)
|
||||
.on("touchmove.drag", touchmoved, nonpassive)
|
||||
.on("touchend.drag touchcancel.drag", touchended)
|
||||
.style("touch-action", "none")
|
||||
.style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
|
||||
}
|
||||
|
||||
function mousedowned(event, d) {
|
||||
if (touchending || !filter.call(this, event, d)) return;
|
||||
var gesture = beforestart(this, container.call(this, event, d), event, d, "mouse");
|
||||
if (!gesture) return;
|
||||
d3Selection.select(event.view)
|
||||
.on("mousemove.drag", mousemoved, nonpassivecapture)
|
||||
.on("mouseup.drag", mouseupped, nonpassivecapture);
|
||||
nodrag(event.view);
|
||||
nopropagation(event);
|
||||
mousemoving = false;
|
||||
mousedownx = event.clientX;
|
||||
mousedowny = event.clientY;
|
||||
gesture("start", event);
|
||||
}
|
||||
|
||||
function mousemoved(event) {
|
||||
noevent(event);
|
||||
if (!mousemoving) {
|
||||
var dx = event.clientX - mousedownx, dy = event.clientY - mousedowny;
|
||||
mousemoving = dx * dx + dy * dy > clickDistance2;
|
||||
}
|
||||
gestures.mouse("drag", event);
|
||||
}
|
||||
|
||||
function mouseupped(event) {
|
||||
d3Selection.select(event.view).on("mousemove.drag mouseup.drag", null);
|
||||
yesdrag(event.view, mousemoving);
|
||||
noevent(event);
|
||||
gestures.mouse("end", event);
|
||||
}
|
||||
|
||||
function touchstarted(event, d) {
|
||||
if (!filter.call(this, event, d)) return;
|
||||
var touches = event.changedTouches,
|
||||
c = container.call(this, event, d),
|
||||
n = touches.length, i, gesture;
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (gesture = beforestart(this, c, event, d, touches[i].identifier, touches[i])) {
|
||||
nopropagation(event);
|
||||
gesture("start", event, touches[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function touchmoved(event) {
|
||||
var touches = event.changedTouches,
|
||||
n = touches.length, i, gesture;
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (gesture = gestures[touches[i].identifier]) {
|
||||
noevent(event);
|
||||
gesture("drag", event, touches[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function touchended(event) {
|
||||
var touches = event.changedTouches,
|
||||
n = touches.length, i, gesture;
|
||||
|
||||
if (touchending) clearTimeout(touchending);
|
||||
touchending = setTimeout(function() { touchending = null; }, 500); // Ghost clicks are delayed!
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (gesture = gestures[touches[i].identifier]) {
|
||||
nopropagation(event);
|
||||
gesture("end", event, touches[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function beforestart(that, container, event, d, identifier, touch) {
|
||||
var dispatch = listeners.copy(),
|
||||
p = d3Selection.pointer(touch || event, container), dx, dy,
|
||||
s;
|
||||
|
||||
if ((s = subject.call(that, new DragEvent("beforestart", {
|
||||
sourceEvent: event,
|
||||
target: drag,
|
||||
identifier,
|
||||
active,
|
||||
x: p[0],
|
||||
y: p[1],
|
||||
dx: 0,
|
||||
dy: 0,
|
||||
dispatch
|
||||
}), d)) == null) return;
|
||||
|
||||
dx = s.x - p[0] || 0;
|
||||
dy = s.y - p[1] || 0;
|
||||
|
||||
return function gesture(type, event, touch) {
|
||||
var p0 = p, n;
|
||||
switch (type) {
|
||||
case "start": gestures[identifier] = gesture, n = active++; break;
|
||||
case "end": delete gestures[identifier], --active; // falls through
|
||||
case "drag": p = d3Selection.pointer(touch || event, container), n = active; break;
|
||||
}
|
||||
dispatch.call(
|
||||
type,
|
||||
that,
|
||||
new DragEvent(type, {
|
||||
sourceEvent: event,
|
||||
subject: s,
|
||||
target: drag,
|
||||
identifier,
|
||||
active: n,
|
||||
x: p[0] + dx,
|
||||
y: p[1] + dy,
|
||||
dx: p[0] - p0[0],
|
||||
dy: p[1] - p0[1],
|
||||
dispatch
|
||||
}),
|
||||
d
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
drag.filter = function(_) {
|
||||
return arguments.length ? (filter = typeof _ === "function" ? _ : constant(!!_), drag) : filter;
|
||||
};
|
||||
|
||||
drag.container = function(_) {
|
||||
return arguments.length ? (container = typeof _ === "function" ? _ : constant(_), drag) : container;
|
||||
};
|
||||
|
||||
drag.subject = function(_) {
|
||||
return arguments.length ? (subject = typeof _ === "function" ? _ : constant(_), drag) : subject;
|
||||
};
|
||||
|
||||
drag.touchable = function(_) {
|
||||
return arguments.length ? (touchable = typeof _ === "function" ? _ : constant(!!_), drag) : touchable;
|
||||
};
|
||||
|
||||
drag.on = function() {
|
||||
var value = listeners.on.apply(listeners, arguments);
|
||||
return value === listeners ? drag : value;
|
||||
};
|
||||
|
||||
drag.clickDistance = function(_) {
|
||||
return arguments.length ? (clickDistance2 = (_ = +_) * _, drag) : Math.sqrt(clickDistance2);
|
||||
};
|
||||
|
||||
return drag;
|
||||
}
|
||||
|
||||
exports.drag = drag;
|
||||
exports.dragDisable = nodrag;
|
||||
exports.dragEnable = yesdrag;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
2
node_modules/d3-drag/dist/d3-drag.min.js
generated
vendored
Normal file
2
node_modules/d3-drag/dist/d3-drag.min.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// https://d3js.org/d3-drag/ v3.0.0 Copyright 2010-2021 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="undefined"!=typeof globalThis?globalThis:e||self).d3=e.d3||{},e.d3,e.d3)}(this,(function(e,t,n){"use strict";const o={passive:!1},r={capture:!0,passive:!1};function i(e){e.stopImmediatePropagation()}function a(e){e.preventDefault(),e.stopImmediatePropagation()}function u(e){var t=e.document.documentElement,o=n.select(e).on("dragstart.drag",a,r);"onselectstart"in t?o.on("selectstart.drag",a,r):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function c(e,t){var o=e.document.documentElement,i=n.select(e).on("dragstart.drag",null);t&&(i.on("click.drag",a,r),setTimeout((function(){i.on("click.drag",null)}),0)),"onselectstart"in o?i.on("selectstart.drag",null):(o.style.MozUserSelect=o.__noselect,delete o.__noselect)}var l=e=>()=>e;function s(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:a,y:u,dx:c,dy:l,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:s}})}function d(e){return!e.ctrlKey&&!e.button}function f(){return this.parentNode}function g(e,t){return null==t?{x:e.x,y:e.y}:t}function h(){return navigator.maxTouchPoints||"ontouchstart"in this}s.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e},e.drag=function(){var e,v,p,b,m=d,y=f,x=g,_=h,w={},T=t.dispatch("start","drag","end"),j=0,E=0;function k(e){e.on("mousedown.drag",M).filter(_).on("touchstart.drag",z).on("touchmove.drag",D,o).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function M(t,o){if(!b&&m.call(this,t,o)){var a=U(this,y.call(this,t,o),t,o,"mouse");a&&(n.select(t.view).on("mousemove.drag",P,r).on("mouseup.drag",q,r),u(t.view),i(t),p=!1,e=t.clientX,v=t.clientY,a("start",t))}}function P(t){if(a(t),!p){var n=t.clientX-e,o=t.clientY-v;p=n*n+o*o>E}w.mouse("drag",t)}function q(e){n.select(e.view).on("mousemove.drag mouseup.drag",null),c(e.view,p),a(e),w.mouse("end",e)}function z(e,t){if(m.call(this,e,t)){var n,o,r=e.changedTouches,a=y.call(this,e,t),u=r.length;for(n=0;n<u;++n)(o=U(this,a,e,t,r[n].identifier,r[n]))&&(i(e),o("start",e,r[n]))}}function D(e){var t,n,o=e.changedTouches,r=o.length;for(t=0;t<r;++t)(n=w[o[t].identifier])&&(a(e),n("drag",e,o[t]))}function S(e){var t,n,o=e.changedTouches,r=o.length;for(b&&clearTimeout(b),b=setTimeout((function(){b=null}),500),t=0;t<r;++t)(n=w[o[t].identifier])&&(i(e),n("end",e,o[t]))}function U(e,t,o,r,i,a){var u,c,l,d=T.copy(),f=n.pointer(a||o,t);if(null!=(l=x.call(e,new s("beforestart",{sourceEvent:o,target:k,identifier:i,active:j,x:f[0],y:f[1],dx:0,dy:0,dispatch:d}),r)))return u=l.x-f[0]||0,c=l.y-f[1]||0,function o(a,g,h){var v,p=f;switch(a){case"start":w[i]=o,v=j++;break;case"end":delete w[i],--j;case"drag":f=n.pointer(h||g,t),v=j}d.call(a,e,new s(a,{sourceEvent:g,subject:l,target:k,identifier:i,active:v,x:f[0]+u,y:f[1]+c,dx:f[0]-p[0],dy:f[1]-p[1],dispatch:d}),r)}}return k.filter=function(e){return arguments.length?(m="function"==typeof e?e:l(!!e),k):m},k.container=function(e){return arguments.length?(y="function"==typeof e?e:l(e),k):y},k.subject=function(e){return arguments.length?(x="function"==typeof e?e:l(e),k):x},k.touchable=function(e){return arguments.length?(_="function"==typeof e?e:l(!!e),k):_},k.on=function(){var e=T.on.apply(T,arguments);return e===T?k:e},k.clickDistance=function(e){return arguments.length?(E=(e=+e)*e,k):Math.sqrt(E)},k},e.dragDisable=u,e.dragEnable=c,Object.defineProperty(e,"__esModule",{value:!0})}));
|
||||
Reference in New Issue
Block a user