add lisp packages
This commit is contained in:
5
lisp/emacs-application-framework/app/mermaid/node_modules/d3-drag/src/constant.js
generated
vendored
Normal file
5
lisp/emacs-application-framework/app/mermaid/node_modules/d3-drag/src/constant.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export default function(x) {
|
||||
return function() {
|
||||
return x;
|
||||
};
|
||||
}
|
||||
167
lisp/emacs-application-framework/app/mermaid/node_modules/d3-drag/src/drag.js
generated
vendored
Normal file
167
lisp/emacs-application-framework/app/mermaid/node_modules/d3-drag/src/drag.js
generated
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
import {dispatch} from "d3-dispatch";
|
||||
import {event, customEvent, select, mouse, touch} from "d3-selection";
|
||||
import nodrag, {yesdrag} from "./nodrag.js";
|
||||
import noevent, {nopropagation} from "./noevent.js";
|
||||
import constant from "./constant.js";
|
||||
import DragEvent from "./event.js";
|
||||
|
||||
// Ignore right-click, since that should open the context menu.
|
||||
function defaultFilter() {
|
||||
return !event.ctrlKey && !event.button;
|
||||
}
|
||||
|
||||
function defaultContainer() {
|
||||
return this.parentNode;
|
||||
}
|
||||
|
||||
function defaultSubject(d) {
|
||||
return d == null ? {x: event.x, y: event.y} : d;
|
||||
}
|
||||
|
||||
function defaultTouchable() {
|
||||
return navigator.maxTouchPoints || ("ontouchstart" in this);
|
||||
}
|
||||
|
||||
export default function() {
|
||||
var filter = defaultFilter,
|
||||
container = defaultContainer,
|
||||
subject = defaultSubject,
|
||||
touchable = defaultTouchable,
|
||||
gestures = {},
|
||||
listeners = 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)
|
||||
.on("touchend.drag touchcancel.drag", touchended)
|
||||
.style("touch-action", "none")
|
||||
.style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
|
||||
}
|
||||
|
||||
function mousedowned() {
|
||||
if (touchending || !filter.apply(this, arguments)) return;
|
||||
var gesture = beforestart("mouse", container.apply(this, arguments), mouse, this, arguments);
|
||||
if (!gesture) return;
|
||||
select(event.view).on("mousemove.drag", mousemoved, true).on("mouseup.drag", mouseupped, true);
|
||||
nodrag(event.view);
|
||||
nopropagation();
|
||||
mousemoving = false;
|
||||
mousedownx = event.clientX;
|
||||
mousedowny = event.clientY;
|
||||
gesture("start");
|
||||
}
|
||||
|
||||
function mousemoved() {
|
||||
noevent();
|
||||
if (!mousemoving) {
|
||||
var dx = event.clientX - mousedownx, dy = event.clientY - mousedowny;
|
||||
mousemoving = dx * dx + dy * dy > clickDistance2;
|
||||
}
|
||||
gestures.mouse("drag");
|
||||
}
|
||||
|
||||
function mouseupped() {
|
||||
select(event.view).on("mousemove.drag mouseup.drag", null);
|
||||
yesdrag(event.view, mousemoving);
|
||||
noevent();
|
||||
gestures.mouse("end");
|
||||
}
|
||||
|
||||
function touchstarted() {
|
||||
if (!filter.apply(this, arguments)) return;
|
||||
var touches = event.changedTouches,
|
||||
c = container.apply(this, arguments),
|
||||
n = touches.length, i, gesture;
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (gesture = beforestart(touches[i].identifier, c, touch, this, arguments)) {
|
||||
nopropagation();
|
||||
gesture("start");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function touchmoved() {
|
||||
var touches = event.changedTouches,
|
||||
n = touches.length, i, gesture;
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (gesture = gestures[touches[i].identifier]) {
|
||||
noevent();
|
||||
gesture("drag");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function touchended() {
|
||||
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();
|
||||
gesture("end");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function beforestart(id, container, point, that, args) {
|
||||
var p = point(container, id), s, dx, dy,
|
||||
sublisteners = listeners.copy();
|
||||
|
||||
if (!customEvent(new DragEvent(drag, "beforestart", s, id, active, p[0], p[1], 0, 0, sublisteners), function() {
|
||||
if ((event.subject = s = subject.apply(that, args)) == null) return false;
|
||||
dx = s.x - p[0] || 0;
|
||||
dy = s.y - p[1] || 0;
|
||||
return true;
|
||||
})) return;
|
||||
|
||||
return function gesture(type) {
|
||||
var p0 = p, n;
|
||||
switch (type) {
|
||||
case "start": gestures[id] = gesture, n = active++; break;
|
||||
case "end": delete gestures[id], --active; // nobreak
|
||||
case "drag": p = point(container, id), n = active; break;
|
||||
}
|
||||
customEvent(new DragEvent(drag, type, s, id, n, p[0] + dx, p[1] + dy, p[0] - p0[0], p[1] - p0[1], sublisteners), sublisteners.apply, sublisteners, [type, that, args]);
|
||||
};
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
17
lisp/emacs-application-framework/app/mermaid/node_modules/d3-drag/src/event.js
generated
vendored
Normal file
17
lisp/emacs-application-framework/app/mermaid/node_modules/d3-drag/src/event.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
export default function DragEvent(target, type, subject, id, active, x, y, dx, dy, dispatch) {
|
||||
this.target = target;
|
||||
this.type = type;
|
||||
this.subject = subject;
|
||||
this.identifier = id;
|
||||
this.active = active;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.dx = dx;
|
||||
this.dy = dy;
|
||||
this._ = dispatch;
|
||||
}
|
||||
|
||||
DragEvent.prototype.on = function() {
|
||||
var value = this._.on.apply(this._, arguments);
|
||||
return value === this._ ? this : value;
|
||||
};
|
||||
2
lisp/emacs-application-framework/app/mermaid/node_modules/d3-drag/src/index.js
generated
vendored
Normal file
2
lisp/emacs-application-framework/app/mermaid/node_modules/d3-drag/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export {default as drag} from "./drag.js";
|
||||
export {default as dragDisable, yesdrag as dragEnable} from "./nodrag.js";
|
||||
28
lisp/emacs-application-framework/app/mermaid/node_modules/d3-drag/src/nodrag.js
generated
vendored
Normal file
28
lisp/emacs-application-framework/app/mermaid/node_modules/d3-drag/src/nodrag.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import {select} from "d3-selection";
|
||||
import noevent from "./noevent.js";
|
||||
|
||||
export default function(view) {
|
||||
var root = view.document.documentElement,
|
||||
selection = select(view).on("dragstart.drag", noevent, true);
|
||||
if ("onselectstart" in root) {
|
||||
selection.on("selectstart.drag", noevent, true);
|
||||
} else {
|
||||
root.__noselect = root.style.MozUserSelect;
|
||||
root.style.MozUserSelect = "none";
|
||||
}
|
||||
}
|
||||
|
||||
export function yesdrag(view, noclick) {
|
||||
var root = view.document.documentElement,
|
||||
selection = select(view).on("dragstart.drag", null);
|
||||
if (noclick) {
|
||||
selection.on("click.drag", noevent, true);
|
||||
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;
|
||||
}
|
||||
}
|
||||
10
lisp/emacs-application-framework/app/mermaid/node_modules/d3-drag/src/noevent.js
generated
vendored
Normal file
10
lisp/emacs-application-framework/app/mermaid/node_modules/d3-drag/src/noevent.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import {event} from "d3-selection";
|
||||
|
||||
export function nopropagation() {
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
|
||||
export default function() {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
Reference in New Issue
Block a user