Node-Red configuration
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

d3-drag.js 8.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. // https://d3js.org/d3-drag/ v3.0.0 Copyright 2010-2021 Mike Bostock
  2. (function (global, factory) {
  3. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-dispatch'), require('d3-selection')) :
  4. typeof define === 'function' && define.amd ? define(['exports', 'd3-dispatch', 'd3-selection'], factory) :
  5. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {}, global.d3, global.d3));
  6. }(this, (function (exports, d3Dispatch, d3Selection) { 'use strict';
  7. // These are typically used in conjunction with noevent to ensure that we can
  8. // preventDefault on the event.
  9. const nonpassive = {passive: false};
  10. const nonpassivecapture = {capture: true, passive: false};
  11. function nopropagation(event) {
  12. event.stopImmediatePropagation();
  13. }
  14. function noevent(event) {
  15. event.preventDefault();
  16. event.stopImmediatePropagation();
  17. }
  18. function nodrag(view) {
  19. var root = view.document.documentElement,
  20. selection = d3Selection.select(view).on("dragstart.drag", noevent, nonpassivecapture);
  21. if ("onselectstart" in root) {
  22. selection.on("selectstart.drag", noevent, nonpassivecapture);
  23. } else {
  24. root.__noselect = root.style.MozUserSelect;
  25. root.style.MozUserSelect = "none";
  26. }
  27. }
  28. function yesdrag(view, noclick) {
  29. var root = view.document.documentElement,
  30. selection = d3Selection.select(view).on("dragstart.drag", null);
  31. if (noclick) {
  32. selection.on("click.drag", noevent, nonpassivecapture);
  33. setTimeout(function() { selection.on("click.drag", null); }, 0);
  34. }
  35. if ("onselectstart" in root) {
  36. selection.on("selectstart.drag", null);
  37. } else {
  38. root.style.MozUserSelect = root.__noselect;
  39. delete root.__noselect;
  40. }
  41. }
  42. var constant = x => () => x;
  43. function DragEvent(type, {
  44. sourceEvent,
  45. subject,
  46. target,
  47. identifier,
  48. active,
  49. x, y, dx, dy,
  50. dispatch
  51. }) {
  52. Object.defineProperties(this, {
  53. type: {value: type, enumerable: true, configurable: true},
  54. sourceEvent: {value: sourceEvent, enumerable: true, configurable: true},
  55. subject: {value: subject, enumerable: true, configurable: true},
  56. target: {value: target, enumerable: true, configurable: true},
  57. identifier: {value: identifier, enumerable: true, configurable: true},
  58. active: {value: active, enumerable: true, configurable: true},
  59. x: {value: x, enumerable: true, configurable: true},
  60. y: {value: y, enumerable: true, configurable: true},
  61. dx: {value: dx, enumerable: true, configurable: true},
  62. dy: {value: dy, enumerable: true, configurable: true},
  63. _: {value: dispatch}
  64. });
  65. }
  66. DragEvent.prototype.on = function() {
  67. var value = this._.on.apply(this._, arguments);
  68. return value === this._ ? this : value;
  69. };
  70. // Ignore right-click, since that should open the context menu.
  71. function defaultFilter(event) {
  72. return !event.ctrlKey && !event.button;
  73. }
  74. function defaultContainer() {
  75. return this.parentNode;
  76. }
  77. function defaultSubject(event, d) {
  78. return d == null ? {x: event.x, y: event.y} : d;
  79. }
  80. function defaultTouchable() {
  81. return navigator.maxTouchPoints || ("ontouchstart" in this);
  82. }
  83. function drag() {
  84. var filter = defaultFilter,
  85. container = defaultContainer,
  86. subject = defaultSubject,
  87. touchable = defaultTouchable,
  88. gestures = {},
  89. listeners = d3Dispatch.dispatch("start", "drag", "end"),
  90. active = 0,
  91. mousedownx,
  92. mousedowny,
  93. mousemoving,
  94. touchending,
  95. clickDistance2 = 0;
  96. function drag(selection) {
  97. selection
  98. .on("mousedown.drag", mousedowned)
  99. .filter(touchable)
  100. .on("touchstart.drag", touchstarted)
  101. .on("touchmove.drag", touchmoved, nonpassive)
  102. .on("touchend.drag touchcancel.drag", touchended)
  103. .style("touch-action", "none")
  104. .style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  105. }
  106. function mousedowned(event, d) {
  107. if (touchending || !filter.call(this, event, d)) return;
  108. var gesture = beforestart(this, container.call(this, event, d), event, d, "mouse");
  109. if (!gesture) return;
  110. d3Selection.select(event.view)
  111. .on("mousemove.drag", mousemoved, nonpassivecapture)
  112. .on("mouseup.drag", mouseupped, nonpassivecapture);
  113. nodrag(event.view);
  114. nopropagation(event);
  115. mousemoving = false;
  116. mousedownx = event.clientX;
  117. mousedowny = event.clientY;
  118. gesture("start", event);
  119. }
  120. function mousemoved(event) {
  121. noevent(event);
  122. if (!mousemoving) {
  123. var dx = event.clientX - mousedownx, dy = event.clientY - mousedowny;
  124. mousemoving = dx * dx + dy * dy > clickDistance2;
  125. }
  126. gestures.mouse("drag", event);
  127. }
  128. function mouseupped(event) {
  129. d3Selection.select(event.view).on("mousemove.drag mouseup.drag", null);
  130. yesdrag(event.view, mousemoving);
  131. noevent(event);
  132. gestures.mouse("end", event);
  133. }
  134. function touchstarted(event, d) {
  135. if (!filter.call(this, event, d)) return;
  136. var touches = event.changedTouches,
  137. c = container.call(this, event, d),
  138. n = touches.length, i, gesture;
  139. for (i = 0; i < n; ++i) {
  140. if (gesture = beforestart(this, c, event, d, touches[i].identifier, touches[i])) {
  141. nopropagation(event);
  142. gesture("start", event, touches[i]);
  143. }
  144. }
  145. }
  146. function touchmoved(event) {
  147. var touches = event.changedTouches,
  148. n = touches.length, i, gesture;
  149. for (i = 0; i < n; ++i) {
  150. if (gesture = gestures[touches[i].identifier]) {
  151. noevent(event);
  152. gesture("drag", event, touches[i]);
  153. }
  154. }
  155. }
  156. function touchended(event) {
  157. var touches = event.changedTouches,
  158. n = touches.length, i, gesture;
  159. if (touchending) clearTimeout(touchending);
  160. touchending = setTimeout(function() { touchending = null; }, 500); // Ghost clicks are delayed!
  161. for (i = 0; i < n; ++i) {
  162. if (gesture = gestures[touches[i].identifier]) {
  163. nopropagation(event);
  164. gesture("end", event, touches[i]);
  165. }
  166. }
  167. }
  168. function beforestart(that, container, event, d, identifier, touch) {
  169. var dispatch = listeners.copy(),
  170. p = d3Selection.pointer(touch || event, container), dx, dy,
  171. s;
  172. if ((s = subject.call(that, new DragEvent("beforestart", {
  173. sourceEvent: event,
  174. target: drag,
  175. identifier,
  176. active,
  177. x: p[0],
  178. y: p[1],
  179. dx: 0,
  180. dy: 0,
  181. dispatch
  182. }), d)) == null) return;
  183. dx = s.x - p[0] || 0;
  184. dy = s.y - p[1] || 0;
  185. return function gesture(type, event, touch) {
  186. var p0 = p, n;
  187. switch (type) {
  188. case "start": gestures[identifier] = gesture, n = active++; break;
  189. case "end": delete gestures[identifier], --active; // falls through
  190. case "drag": p = d3Selection.pointer(touch || event, container), n = active; break;
  191. }
  192. dispatch.call(
  193. type,
  194. that,
  195. new DragEvent(type, {
  196. sourceEvent: event,
  197. subject: s,
  198. target: drag,
  199. identifier,
  200. active: n,
  201. x: p[0] + dx,
  202. y: p[1] + dy,
  203. dx: p[0] - p0[0],
  204. dy: p[1] - p0[1],
  205. dispatch
  206. }),
  207. d
  208. );
  209. };
  210. }
  211. drag.filter = function(_) {
  212. return arguments.length ? (filter = typeof _ === "function" ? _ : constant(!!_), drag) : filter;
  213. };
  214. drag.container = function(_) {
  215. return arguments.length ? (container = typeof _ === "function" ? _ : constant(_), drag) : container;
  216. };
  217. drag.subject = function(_) {
  218. return arguments.length ? (subject = typeof _ === "function" ? _ : constant(_), drag) : subject;
  219. };
  220. drag.touchable = function(_) {
  221. return arguments.length ? (touchable = typeof _ === "function" ? _ : constant(!!_), drag) : touchable;
  222. };
  223. drag.on = function() {
  224. var value = listeners.on.apply(listeners, arguments);
  225. return value === listeners ? drag : value;
  226. };
  227. drag.clickDistance = function(_) {
  228. return arguments.length ? (clickDistance2 = (_ = +_) * _, drag) : Math.sqrt(clickDistance2);
  229. };
  230. return drag;
  231. }
  232. exports.drag = drag;
  233. exports.dragDisable = nodrag;
  234. exports.dragEnable = yesdrag;
  235. Object.defineProperty(exports, '__esModule', { value: true });
  236. })));