pluto/core/static/js/magnet.min.js

2 lines
157 KiB
JavaScript
Raw Permalink Normal View History

2023-03-05 20:09:31 +00:00
(()=>{"use strict";const t=function(t,e){return t instanceof DOMPoint?DOMPoint.fromPoint(t):t instanceof DOMRect?new DOMPoint(t.x,t.y):new DOMPoint(t,e)},e=t;function n(e){const{best:n}=e;return t(n.x?.rawDistance??0,n.y?.rawDistance??0)}const a=/[|;,\s]/;function s(t,e){if(null===t)return[];const n=t.split(a);return void 0===e?n:Object.values(e).filter((t=>n.includes(t)))}function o(t,e){const n=Array.isArray(t)?t:[t];return void 0===e?n.join("|"):Object.values(e).filter((t=>n.includes(t))).join("|")}const r=function(t,e){return customElements.get(e)?Promise.reject(new Error(`Already defined <${e}>`)):(customElements.define(e,t),customElements.whenDefined(e))};var i;!function(t){t.topToTop="topToTop",t.topToBottom="topToBottom",t.rightToRight="rightToRight",t.rightToLeft="rightToLeft",t.bottomToTop="bottomToTop",t.bottomToBottom="bottomToBottom",t.leftToRight="leftToRight",t.leftToLeft="leftToLeft",t.xCenterToXCenter="xCenterToXCenter",t.yCenterToYCenter="yCenterToYCenter"}(i||(i={}));const c=[i.rightToRight,i.rightToLeft,i.leftToRight,i.leftToLeft,i.xCenterToXCenter],l=[i.topToTop,i.topToBottom,i.bottomToTop,i.bottomToBottom,i.yCenterToYCenter],u=i;var g;let h;!function(t){t.outer="outer",t.inner="inner",t.center="center",t.extend="extend"}(g||(g={})),function(t){t.inner="inner",t.center="center"}(h||(h={}));const f=g;var d;!function(t){t.disabled="disabled",t.group="group",t.unattractable="unattractable",t.unmovable="unmovable",t.attractDistance="attract-distance",t.alignTo="align-to",t.alignToParent="align-to-parent",t.crossPrevent="cross-prevent",t.offsetUnit="offset-unit"}(d||(d={}));const m=d;var b;!function(t){t.parent="parent"}(b||(b={}));const p=b;var T;!function(t){t.magnetstart="magnetstart",t.magnetmove="magnetmove",t.magnetend="magnetend",t.attract="attract",t.attracted="attracted",t.attractmove="attractmove",t.attractedmove="attractedmove",t.unattract="unattract",t.unattracted="unattracted"}(T||(T={}));const y=T;var D;!function(t){t.pixel="px",t.px="px",t.percentage="%",t["%"]="%"}(D||(D={}));const x=D,{isNaN:v}=globalThis,{abs:P}=Math,A=document.createElement("template"),M={[m.disabled]:!1,[m.group]:null,[m.attractDistance]:10,[m.unattractable]:!1,[m.unmovable]:!1,get[m.alignTo](){return[f.outer,f.center,f.extend]},get[m.alignToParent](){return[]},get[m.crossPrevent](){return[]},[m.offsetUnit]:x.pixel};A.innerHTML="\n <style>\n :host {\n position: relative;\n display: inline-block;\n }\n </style>\n <slot>\n </slot>\n";class w extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.append(A.content.cloneNode(!0))}static get ALIGNMENT(){return{...u}}static get ALIGN_TO(){return{...f}}static get ALIGN_TO_PARENT(){return{...h}}static get CROSS_PREVENT(){return{...p}}static get EVENT(){return{...y}}static getAlignmentsFromAlignTo(t){const e=Array.isArray(t)?t:[t],n=[];return e.includes(f.outer)&&n.push(u.topToBottom,u.rightToLeft,u.bottomToTop,u.leftToRight),e.includes(f.inner)&&n.push(u.topToTop,u.rightToRight,u.bottomToBottom,u.leftToLeft),e.includes(f.center)&&n.push(u.xCenterToXCenter,u.yCenterToYCenter),n}static getMagnetAttractionOffset=n;get disabled(){return null!==this.traceMagnetAttributeValue(m.disabled)}set disabled(t){t?this.setAttribute(m.disabled,""):this.removeAttribute(m.disabled)}get group(){return this.traceMagnetAttributeValue(m.group)}set group(t){null===t||0===t.length?this.removeAttribute(m.group):this.setAttribute(m.group,t)}get parentMagnet(){const t=this.getAttribute(m.group);let e=this.parentElement;for(;e;){if(e instanceof w){const n=e.getAttribute(m.group);if(null===t||null===n||t===n)return e}e=e.parentElement}return null}get unattractable(){return null!==this.traceMagnetAttributeValue(m.unattractable)}set unattractable(t){t?this.setAttribute(m.unattractable,""):this.removeAttribute(m.unattractable)}get unmovable(){return null!==this.traceMagnetAttributeValue(m.unmovable)}set unmovable(t){t?this.setAttrib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