mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-09-07 05:14:42 +02:00
1 line
16 KiB
Plaintext
1 line
16 KiB
Plaintext
|
{"version":3,"file":"ext-overview_window.js","sources":["../../../../src/editor/extensions/ext-overview_window/dragmove/dragmove.js","../../../../src/editor/extensions/ext-overview_window/ext-overview_window.js"],"sourcesContent":["// https://github.com/knadh/dragmove.js\n// Kailash Nadh (c) 2020.\n// MIT License.\n// can't use npm version as the dragmove is different.\n\nlet _loaded = false\nconst _callbacks = []\nconst _isTouch = window.ontouchstart !== undefined\n\nexport const dragmove = function (target, handler, parent, onStart, onEnd, onDrag) {\n // Register a global event to capture mouse moves (once).\n if (!_loaded) {\n document.addEventListener(_isTouch ? 'touchmove' : 'mousemove', function (e) {\n let c = e\n if (e.touches) {\n c = e.touches[0]\n }\n\n // On mouse move, dispatch the coords to all registered callbacks.\n for (let i = 0; i < _callbacks.length; i++) {\n _callbacks[i](c.clientX, c.clientY)\n }\n })\n }\n\n _loaded = true\n let isMoving = false; let hasStarted = false\n let startX = 0; let startY = 0; let lastX = 0; let lastY = 0\n\n // On the first click and hold, record the offset of the pointer in relation\n // to the point of click inside the element.\n handler.addEventListener(_isTouch ? 'touchstart' : 'mousedown', function (e) {\n e.stopPropagation()\n e.preventDefault()\n if (target.dataset.dragEnabled === 'false') {\n return\n }\n\n let c = e\n if (e.touches) {\n c = e.touches[0]\n }\n\n isMoving = true\n startX = target.offsetLeft - c.clientX\n startY = target.offsetTop - c.clientY\n })\n\n // On leaving click, stop moving.\n document.addEventListener(_isTouch ? 'touchend' : 'mouseup', function () {\n if (onEnd && hasStarted) {\n onEnd(target, parent, parseInt(target.style.left), parseInt(target.style.top))\n }\n\n isMoving = false\n hasStarted = false\n })\n\n // On leaving click, stop moving.\n document.addEventListener(_isTouch ? 'touchmove' : 'mousemove', function () {\n if (onDrag && hasStarted) {\n onDrag(target, parseInt(target.style.left), parseInt(target.style.top))\n }\n })\n\n // Register mouse-move callback to move the element.\n _callbacks.push(function move (x, y) {\n if (!isMoving) {\n return\n }\n\n if (!hasStarted) {\n hasStarted = true\n if (onStart) {\n onStart(target, lastX, lastY)\n }\n }\n\n lastX = x + startX\n lastY = y + startY\n\n // If boundary checking is on, don't let the element cross the viewport.\n if (target.dataset.dragBoundary === 'true') {\n if (lastX < 1 || lastX >= window.innerWidth - target.offsetWidth) {\n return\n }\n if (lastY < 1 || lastY >= window.innerHeight - target.offsetHeight) {\n return\n }\n }\n\n target.style.left = lastX + 'px'\n target.style.top = lastY + 'px'\n })\n}\n\nexport { dragmove as default }\n","/**\n * @file ext-overview_window.js\n *\n * @license MIT\n *\n * @copyright 2013 James Sacksteder\n *\n */\nimport { dragmove } from './dragmove/dragmove.js'\n\nexport default {\n name: 'overview_window',\n init ({ _$ }) {\n const svgEditor = this\n const { $id, $click } = svgEditor.svgCanvas\n const overviewWindowGlobals = {}\n\n // Define and insert the base html element.\n const propsWindowHtml =\n '<div id=\"overview_window_content_pane\" style=\"width:100%; word-wrap:break-word; display:inline-block; margin-top:20px;\">' +\n '<div id=\"overview_window_content\" style=\"position:relative; padding-left:15px; top:0px;\">' +\n '<div style=\"background-color:#A0A0A0; display:inline-block; overflow:visible;\">' +\n '<svg id=\"overviewMiniView\" width=\"132\" height=\"100\" x=\"0\" y=\"0\" viewBox=\"0 0 4800 3600\" ' +\n 'xmlns=\"http://www.w3.org/2000/svg\" ' +\n 'xmlns:xlink=\"http://www.w3.org/1999/xlink\">' +\n '<use x=\"0\" y=\"0\" xlink:href=\"#svgroot\"> </use>' +\n '</svg>' +\n '<div id=
|