diff --git a/.gitignore b/.gitignore index a841f5bc..b2889e12 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,16 @@ ignore node_modules - -svgedit-custom.css - docs/jsdoc - cypress/results cypress/screenshots cypress/videos cypress.env.json - coverage instrumented .nyc_output mochawesome-report mochawesome.json - .vscode .eslintcache .DS_Store +.idea diff --git a/gh-disabled-workflows/coverage.yml b/archive/gh-disabled-workflows/coverage.yml similarity index 100% rename from gh-disabled-workflows/coverage.yml rename to archive/gh-disabled-workflows/coverage.yml diff --git a/gh-disabled-workflows/nodejs.yml b/archive/gh-disabled-workflows/nodejs.yml similarity index 100% rename from gh-disabled-workflows/nodejs.yml rename to archive/gh-disabled-workflows/nodejs.yml diff --git a/gh-disabled-workflows/npmpublish.yml b/archive/gh-disabled-workflows/npmpublish.yml similarity index 100% rename from gh-disabled-workflows/npmpublish.yml rename to archive/gh-disabled-workflows/npmpublish.yml diff --git a/demos/canvas.html b/demos/canvas.html index 81c68a43..321b03c6 100644 --- a/demos/canvas.html +++ b/demos/canvas.html @@ -4,7 +4,6 @@ Minimal demo of SvgCanvas - diff --git a/package-lock.json b/package-lock.json index 50b4f806..8ac25911 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "license": "(MIT AND Apache-2.0 AND ISC AND LGPL-3.0-or-later AND X11)", "dependencies": { "@babel/polyfill": "7.12.1", + "@knadh/dragmove": "^0.1.2", "@web/dev-server-rollup": "0.3.2", "canvg": "3.0.7", "core-js": "3.9.1", @@ -3244,6 +3245,11 @@ "regenerator-runtime": "^0.13.3" } }, + "node_modules/@knadh/dragmove": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@knadh/dragmove/-/dragmove-0.1.2.tgz", + "integrity": "sha512-OxfFFHqrpenz9oVxi8AngzrF7+aoGZCvNOGOVlxu+6UlG0dW68hJJeNt7RvVlg3dNK6uaHsju+bH+/NXaRUMTQ==" + }, "node_modules/@mdn/browser-compat-data": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/@mdn/browser-compat-data/-/browser-compat-data-2.0.7.tgz", @@ -26626,6 +26632,11 @@ "regenerator-runtime": "^0.13.3" } }, + "@knadh/dragmove": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@knadh/dragmove/-/dragmove-0.1.2.tgz", + "integrity": "sha512-OxfFFHqrpenz9oVxi8AngzrF7+aoGZCvNOGOVlxu+6UlG0dW68hJJeNt7RvVlg3dNK6uaHsju+bH+/NXaRUMTQ==" + }, "@mdn/browser-compat-data": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/@mdn/browser-compat-data/-/browser-compat-data-2.0.7.tgz", diff --git a/package.json b/package.json index 56e42e84..d63bf958 100644 --- a/package.json +++ b/package.json @@ -107,6 +107,7 @@ ], "dependencies": { "@babel/polyfill": "7.12.1", + "@knadh/dragmove": "^0.1.2", "@web/dev-server-rollup": "0.3.2", "canvg": "3.0.7", "core-js": "3.9.1", diff --git a/src/editor/dragmove/dragmove.js b/src/editor/dragmove/dragmove.js deleted file mode 100644 index 47c7ca48..00000000 --- a/src/editor/dragmove/dragmove.js +++ /dev/null @@ -1,96 +0,0 @@ -// https://github.com/knadh/dragmove.js -// Kailash Nadh (c) 2020. -// MIT License. - -let _loaded = false; -let _callbacks = []; -const _isTouch = window.ontouchstart !== undefined; - -export const dragmove = function(target, handler, parent, onStart, onEnd, onDrag) { - // Register a global event to capture mouse moves (once). - if (!_loaded) { - document.addEventListener(_isTouch ? "touchmove" : "mousemove", function(e) { - let c = e; - if (e.touches) { - c = e.touches[0]; - } - - // On mouse move, dispatch the coords to all registered callbacks. - for (var i = 0; i < _callbacks.length; i++) { - _callbacks[i](c.clientX, c.clientY); - } - }); - } - - _loaded = true; - let isMoving = false, hasStarted = false; - let startX = 0, startY = 0, lastX = 0, lastY = 0; - - // On the first click and hold, record the offset of the pointer in relation - // to the point of click inside the element. - handler.addEventListener(_isTouch ? "touchstart" : "mousedown", function(e) { - e.stopPropagation(); - e.preventDefault(); - if (target.dataset.dragEnabled === "false") { - return; - } - - let c = e; - if (e.touches) { - c = e.touches[0]; - } - - isMoving = true; - startX = target.offsetLeft - c.clientX; - startY = target.offsetTop - c.clientY; - }); - - // On leaving click, stop moving. - document.addEventListener(_isTouch ? "touchend" : "mouseup", function(e) { - if (onEnd && hasStarted) { - onEnd(target, parent, parseInt(target.style.left), parseInt(target.style.top)); - } - - isMoving = false; - hasStarted = false; - }); - - // On leaving click, stop moving. - document.addEventListener(_isTouch ? "touchmove" : "mousemove", function(e) { - if (onDrag && hasStarted) { - onDrag(target, parseInt(target.style.left), parseInt(target.style.top)); - } - }); - - // Register mouse-move callback to move the element. - _callbacks.push(function move(x, y) { - if (!isMoving) { - return; - } - - if (!hasStarted) { - hasStarted = true; - if (onStart) { - onStart(target, lastX, lastY); - } - } - - lastX = x + startX; - lastY = y + startY; - - // If boundary checking is on, don't let the element cross the viewport. - if (target.dataset.dragBoundary === "true") { - if (lastX < 1 || lastX >= window.innerWidth - target.offsetWidth) { - return; - } - if (lastY < 1 || lastY >= window.innerHeight - target.offsetHeight) { - return; - } - } - - target.style.left = lastX + "px"; - target.style.top = lastY + "px"; - }); -} - -export { dragmove as default }; \ No newline at end of file diff --git a/src/editor/extensions/ext-overview_window/ext-overview_window.js b/src/editor/extensions/ext-overview_window/ext-overview_window.js index 94e9933c..cc6e0bc1 100644 --- a/src/editor/extensions/ext-overview_window/ext-overview_window.js +++ b/src/editor/extensions/ext-overview_window/ext-overview_window.js @@ -6,7 +6,7 @@ * @copyright 2013 James Sacksteder * */ -import { dragmove } from '../../dragmove/dragmove.js'; +import { dragmove } from '@knadh/dragmove'; export default { name: 'overview_window', init ({$, isChrome}) {