diff --git a/src/lib/components/Output/Print/MainSystems/movable.js b/src/lib/components/Output/Print/MainSystems/movable.js index 8b08a50..fab618d 100644 --- a/src/lib/components/Output/Print/MainSystems/movable.js +++ b/src/lib/components/Output/Print/MainSystems/movable.js @@ -1,67 +1,64 @@ import VanillaMoveable, { PROPERTIES, EVENTS } from "moveable"; import { camelize, isUndefined } from "@daybrush/utils"; -function createMoveable(node,options) { +function createMoveable(node, options) { + let translate = [0, 0]; - let translate = [0,0]; - - options = { - originDraggable: true, - originRelative: true, - draggable: true, - throttleDrag: 0, - zoom: 1, - origin: false, + options = { + originDraggable: true, + originRelative: true, + draggable: true, + throttleDrag: 0, + zoom: 1, + origin: false, onDrag(e) { - translate = e.beforeTranslate; - node.dispatchEvent(new CustomEvent('translate', { detail: translate})); + translate = e.beforeTranslate; + node.dispatchEvent(new CustomEvent("translate", { detail: translate })); }, - target: node, - ...options, - }; + target: node, + ...options, + }; - const moveable = new VanillaMoveable(document.body, options ); + const moveable = new VanillaMoveable(document.body, options); - EVENTS.forEach((name) => { - const onName = camelize(`on ${name}`); - moveable.on(name, (e) => { - const result = options[onName] && options[onName](e); - const result2 = node.dispatchEvent(new CustomEvent(name, { detail: e })); + EVENTS.forEach((name) => { + const onName = camelize(`on ${name}`); + moveable.on(name, (e) => { + const result = options[onName] && options[onName](e); + const result2 = node.dispatchEvent(new CustomEvent(name, { detail: e })); - return !isUndefined(result) - ? result - : !isUndefined(result2) - ? result2 - : undefined; - }); + return !isUndefined(result) + ? result + : !isUndefined(result2) + ? result2 + : undefined; }); + }); - return moveable; + return moveable; } export function movable(node, options) { + let moveable = options.disabled ? undefined : createMoveable(options); - let moveable = options.disabled ? undefined : createMoveable(options); + const destroy = () => { + if (!moveable) return; + moveable.destroy(); + moveable = undefined; + }; + const update = async (params) => { + if (params.disabled) { + destroy(); + } else { + if (!moveable) { + moveable = createMoveable(node, params); + } + } + }; - const destroy = () => { - if(!moveable) return; - moveable.destroy(); - moveable = undefined; - }; - - const update = async (params) => { - if (params.disabled) { - destroy(); - } else { - if (!moveable) { - moveable = createMoveable(node, params); - } - } - }; - - return { - destroy, - update, - }; + return { + destroy, + update, + }; } diff --git a/src/lib/components/Output/Print/index.svelte b/src/lib/components/Output/Print/index.svelte index 3a096eb..d31d20d 100644 --- a/src/lib/components/Output/Print/index.svelte +++ b/src/lib/components/Output/Print/index.svelte @@ -41,7 +41,7 @@
Printing this page will only prints the ship sheet.