@roomle/embedding-lib 5.7.0-alpha.1 → 5.7.0-debug.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/md/web/embedding/CHANGELOG.md +37 -1
- package/drag-in-3CJWP_Px.mjs +133 -0
- package/drag-in-sE43chRN.mjs +7 -0
- package/from-custom-view-DmyxPHCr.mjs +165 -0
- package/from-custom-view-Pim0MOO4.mjs +1 -0
- package/from-website-BhUhFYtn.mjs +194 -0
- package/from-website-DInCYX35.mjs +4 -0
- package/index.d.ts +105 -40
- package/package.json +2 -2
- package/roomle-embedding-lib.es.js +343 -262
- package/roomle-embedding-lib.es.min.js +8 -8
- package/roomle-embedding-lib.umd.js +14 -11
- package/roomle-embedding-lib.umd.min.js +17 -14
- package/touch-drag-BsAmrceE.mjs +149 -0
- package/touch-drag-DibgNiRO.mjs +1 -0
- package/drag-in-BKrnFtmJ.mjs +0 -7
- package/drag-in-DC-05b4s.mjs +0 -265
|
@@ -1,11 +1,47 @@
|
|
|
1
|
-
## [5.7.0-
|
|
1
|
+
## [5.7.0-debug.1](https://github.com/roomle-dev/roomle-ui/compare/embedding-lib-v5.6.0...embedding-lib-v5.7.0-debug.1) (2024-11-11)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Features
|
|
5
5
|
|
|
6
|
+
* add example for custom overlay ([cc9f748](https://github.com/roomle-dev/roomle-ui/commit/cc9f748722fd07354ac6e214a24bf8824caa98ae))
|
|
7
|
+
* add onHideCustomView for embedding-callbacks ([afcd9d3](https://github.com/roomle-dev/roomle-ui/commit/afcd9d3746301145e22a4b380152dcc14acae391))
|
|
8
|
+
* enable custom view also if we are not in embedding ([27777b3](https://github.com/roomle-dev/roomle-ui/commit/27777b34b9f68f0d290ab6bbe04d348b924ab591))
|
|
9
|
+
* expose toggle drawer ([7bd69da](https://github.com/roomle-dev/roomle-ui/commit/7bd69dac5a050444ca6f38d29c929805c2ad2e15))
|
|
10
|
+
* Hide the Overall Measurements in Parts List and Parts List Printout based on flag conditionally ([1fc1225](https://github.com/roomle-dev/roomle-ui/commit/1fc1225c4e17617aa69dfaee83377a17c45cb2b9))
|
|
11
|
+
* implement overlay: true ([0d2b66f](https://github.com/roomle-dev/roomle-ui/commit/0d2b66f41976c0a3b61b6e6caabd8b5f4d8dea7a))
|
|
12
|
+
* make communication from child to parent possible ([6d432ab](https://github.com/roomle-dev/roomle-ui/commit/6d432ab6ce892bdee65e4e70ba57b69d78a7f7dc))
|
|
13
|
+
* make custom views better extensible ([56d1e04](https://github.com/roomle-dev/roomle-ui/commit/56d1e046271745ba61728e02a8d6bbda2dd9400b))
|
|
14
|
+
* make it more versatile for HOMAG cases ([705c6da](https://github.com/roomle-dev/roomle-ui/commit/705c6dab2b1982f351cbd1f60dabb6d91ea76197))
|
|
15
|
+
* make it possible that a custom view can connect to us ([7a50358](https://github.com/roomle-dev/roomle-ui/commit/7a50358500e084bcf32635f72f70b4c4dbe354b5))
|
|
16
|
+
* make things more stable ([432c571](https://github.com/roomle-dev/roomle-ui/commit/432c5713b1504e865d3152f888940b72d3767516))
|
|
17
|
+
* move toggle out if we are on overlay ([c247abf](https://github.com/roomle-dev/roomle-ui/commit/c247abfc75b6fe2e0fc59a78ce6caed4b6135c9c))
|
|
18
|
+
* new methods for exposed api ([264d34f](https://github.com/roomle-dev/roomle-ui/commit/264d34fae8e98b259bf4ef0e921622544ecd4bce))
|
|
19
|
+
* overlay ([1d5cc6b](https://github.com/roomle-dev/roomle-ui/commit/1d5cc6b72abf9e7907a44f7ad15bf42fdd925592))
|
|
20
|
+
* some more stuff ([82d0403](https://github.com/roomle-dev/roomle-ui/commit/82d04039902ad8873ab9b35ee6b5bba211076184))
|
|
6
21
|
* **SDK:** upgrade to version 2.88.1-alpha.1 ([15bd1f5](https://github.com/roomle-dev/roomle-ui/commit/15bd1f5c6ae90a27c6d2b78684ce64cc15798aca))
|
|
22
|
+
* **SDK:** upgrade to version 2.89.0-alpha.1 ([45a5fe1](https://github.com/roomle-dev/roomle-ui/commit/45a5fe117322e3c56e849bca5cee90da9d121dfa))
|
|
23
|
+
* **SDK:** upgrade to version 2.89.0-alpha.2 ([#1341](https://github.com/roomle-dev/roomle-ui/issues/1341)) ([05b1993](https://github.com/roomle-dev/roomle-ui/commit/05b199310cd816bca4983dd93f351cb5b39b3371))
|
|
7
24
|
|
|
8
25
|
|
|
9
26
|
### Bug Fixes
|
|
10
27
|
|
|
28
|
+
* add missing new lines ([28d9df7](https://github.com/roomle-dev/roomle-ui/commit/28d9df79c4f617f67e1c27358e58dad972b97db3))
|
|
29
|
+
* do not collapse custom view on main embedding ([829c32e](https://github.com/roomle-dev/roomle-ui/commit/829c32e6ee757c6ea3c29932a4ccce49f4998ef6))
|
|
30
|
+
* drag-touch tests ([cf9eb0a](https://github.com/roomle-dev/roomle-ui/commit/cf9eb0aabf9d3ca34cbc83d9318648f55179ce97))
|
|
31
|
+
* failing tests ([635c6c1](https://github.com/roomle-dev/roomle-ui/commit/635c6c1a9a7cdaa1723f229d08b4b6be20c74ab7))
|
|
11
32
|
* fix URL parameter parsing to handle array-like keys and remove '[]' suffix ([f7783a3](https://github.com/roomle-dev/roomle-ui/commit/f7783a3faa7e3989a7d08434f48d26fe40079447))
|
|
33
|
+
* hide rotation if there is a construction element selected among the milti-selected objects ([fed131a](https://github.com/roomle-dev/roomle-ui/commit/fed131a02245b82d072fed6474e297495ef6ba2b))
|
|
34
|
+
* make drag-in for custom-view more stable against different timings ([3ebd477](https://github.com/roomle-dev/roomle-ui/commit/3ebd47785d3ed030cd8aa316d442223c03644bc1))
|
|
35
|
+
* make typescript happy ([7613796](https://github.com/roomle-dev/roomle-ui/commit/7613796f23b9ed7b815cc280db589e863110123e))
|
|
36
|
+
* make typescript work ([6d14255](https://github.com/roomle-dev/roomle-ui/commit/6d14255f1f9b57fde9a6efc4bb57fa39244b65b3))
|
|
37
|
+
* oxlint destroyed my code ([06a2882](https://github.com/roomle-dev/roomle-ui/commit/06a28824652eb8d972a8d820776ada4676b35787))
|
|
38
|
+
* remove dynamic IDs ([7f8e4e0](https://github.com/roomle-dev/roomle-ui/commit/7f8e4e00f34b7fedc4486f512afd8926e83dd30a))
|
|
39
|
+
* remove merge conflicts ([4a2ceae](https://github.com/roomle-dev/roomle-ui/commit/4a2ceae999db8245bc0e1f8ea4b4f506ea877b3e))
|
|
40
|
+
* some stuff ([f4c0501](https://github.com/roomle-dev/roomle-ui/commit/f4c05015912d2fb077d325602b25acdf3164c2d8))
|
|
41
|
+
* some stuff ([632deb9](https://github.com/roomle-dev/roomle-ui/commit/632deb920125dec7a8af4012ab51b84840811286))
|
|
42
|
+
* things ([8404ff6](https://github.com/roomle-dev/roomle-ui/commit/8404ff688d6c0c07a3920921a7d3bb05ea5995e6))
|
|
43
|
+
* ts ([cbc5407](https://github.com/roomle-dev/roomle-ui/commit/cbc5407d30ed9677a4733f09e463ca7500024bcb))
|
|
44
|
+
* ts errors ([0034978](https://github.com/roomle-dev/roomle-ui/commit/00349784c2153127c0ff4f019cddf9fb81d9d0c8))
|
|
45
|
+
* ts errors ([faaf013](https://github.com/roomle-dev/roomle-ui/commit/faaf0138799af91f21af55a7994e3a4f22de1883))
|
|
46
|
+
* use correct imports so that we do not import all of Vue ([46dc577](https://github.com/roomle-dev/roomle-ui/commit/46dc577592dd88947c07cbf600f2d4988584f5d2))
|
|
47
|
+
* use ResizeObserver and switch back to GPU CSS ([65c3a53](https://github.com/roomle-dev/roomle-ui/commit/65c3a539ed7834d45b6a11eee3695768b5ce2cd1))
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
var S = Object.defineProperty;
|
|
2
|
+
var y = (r, s, t) => s in r ? S(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
|
|
3
|
+
var i = (r, s, t) => y(r, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
+
class I {
|
|
5
|
+
constructor(s, t, e, a) {
|
|
6
|
+
i(this, "_mainDomElement");
|
|
7
|
+
i(this, "_instance");
|
|
8
|
+
i(this, "_mode", "website");
|
|
9
|
+
i(this, "_viewName", "main");
|
|
10
|
+
this._instance = s, this._mainDomElement = t, this._mode = e, this._viewName = a;
|
|
11
|
+
}
|
|
12
|
+
async init() {
|
|
13
|
+
return Promise.resolve();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const m = "rml-drag-in-styles", M = "rml-drag-in-drag-element", E = "rml-drag-in-overlay", g = "rml-drag-in-drag-ghost", h = "rml-drag-in-fade-in", u = "rml-drag-in-fade-out", L = {
|
|
17
|
+
DISPLAY_NONE: "rml-display-none"
|
|
18
|
+
}, A = 0.5, p = "250ms", D = "forwards", N = `@keyframes ${h} {from{opacity: 0;}to {opacity: ${A};}}`, R = `@keyframes ${u} {from{opacity: ${A};}to {opacity: 0;}}`, O = `${h} ${p} ${D}`, b = `${u} ${p} ${D}`, v = "https://res.cloudinary.com/roomle/image/upload/v1729679975/fallback_afpyqr.jpg", w = 112, C = 112;
|
|
19
|
+
class G extends I {
|
|
20
|
+
constructor(t, e, a, _) {
|
|
21
|
+
super(t, e, a, _);
|
|
22
|
+
i(this, "options", {});
|
|
23
|
+
i(this, "_customDragSignal", new AbortController());
|
|
24
|
+
this._mainDomElement = e, this._injectStyles(), this._initializeDragGhost();
|
|
25
|
+
}
|
|
26
|
+
_injectStyles() {
|
|
27
|
+
if (!!!document.getElementById(m)) {
|
|
28
|
+
const e = document.createElement("style");
|
|
29
|
+
e.type = "text/css", e.id = m, e.innerHTML = `
|
|
30
|
+
.${L.DISPLAY_NONE}{display:none}
|
|
31
|
+
.${E}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}
|
|
32
|
+
.${g}{position:absolute;top:0;left:0;width:1px;height:1px;z-index:999;pointer-events:none;background-color:transparent;}
|
|
33
|
+
${N}
|
|
34
|
+
${R}
|
|
35
|
+
`, document.head.appendChild(e);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
_initializeDragGhost() {
|
|
39
|
+
const t = this._mainDomElement.parentNode;
|
|
40
|
+
let e = t.querySelector(
|
|
41
|
+
"." + g
|
|
42
|
+
);
|
|
43
|
+
e || (e = document.createElement("div"), e.classList.add(g), e.innerText = " ", t.appendChild(e));
|
|
44
|
+
}
|
|
45
|
+
async init() {
|
|
46
|
+
if (await super.init(), this._mode === "website") {
|
|
47
|
+
const { DragInFromWebsiteStrategy: t } = await import("./from-website-BhUhFYtn.mjs");
|
|
48
|
+
this._strategy = new t(
|
|
49
|
+
this._instance,
|
|
50
|
+
this._mainDomElement,
|
|
51
|
+
this.options
|
|
52
|
+
);
|
|
53
|
+
} else if (this._mode === "custom-view") {
|
|
54
|
+
const { DragInFromCustomViewStrategy: t } = await import("./from-custom-view-DmyxPHCr.mjs");
|
|
55
|
+
this._strategy = new t(
|
|
56
|
+
this._instance,
|
|
57
|
+
this.options,
|
|
58
|
+
this._viewName
|
|
59
|
+
);
|
|
60
|
+
} else
|
|
61
|
+
throw new Error("Unsupported mode");
|
|
62
|
+
}
|
|
63
|
+
get isDragging() {
|
|
64
|
+
return this._strategy.isDragging;
|
|
65
|
+
}
|
|
66
|
+
dragStart(t, e, a = "rml_id") {
|
|
67
|
+
this._strategy.dragStart(t, e, a);
|
|
68
|
+
}
|
|
69
|
+
dragUpdate(t) {
|
|
70
|
+
this._strategy.dragUpdate(t);
|
|
71
|
+
}
|
|
72
|
+
dragEnd() {
|
|
73
|
+
this._strategy.dragEnd();
|
|
74
|
+
}
|
|
75
|
+
touchStart(t, e, a = "rml_id") {
|
|
76
|
+
this._strategy.touchStart(t, e, a);
|
|
77
|
+
}
|
|
78
|
+
touchMove(t) {
|
|
79
|
+
this._strategy.touchMove(t);
|
|
80
|
+
}
|
|
81
|
+
touchEnd() {
|
|
82
|
+
this._strategy.touchEnd();
|
|
83
|
+
}
|
|
84
|
+
dispose() {
|
|
85
|
+
this._strategy.dispose();
|
|
86
|
+
}
|
|
87
|
+
beforeUpdateGhost(t) {
|
|
88
|
+
this._strategy.beforeUpdateGhost(t);
|
|
89
|
+
}
|
|
90
|
+
registerCustomDrag({
|
|
91
|
+
customDragStart: t,
|
|
92
|
+
customDragEnd: e,
|
|
93
|
+
customDragUpdate: a,
|
|
94
|
+
beforeUpdateGhost: _
|
|
95
|
+
}) {
|
|
96
|
+
_ && this._strategy.beforeUpdateGhost(_);
|
|
97
|
+
const o = this._customDragSignal.signal, c = (n) => {
|
|
98
|
+
n.target.getAttribute("data-rml-draggable") === "true" && t(n);
|
|
99
|
+
}, d = (n) => {
|
|
100
|
+
this._strategy.releaseInput(n), this._strategy.isDragging && e(n);
|
|
101
|
+
}, l = (n) => {
|
|
102
|
+
a(n);
|
|
103
|
+
};
|
|
104
|
+
document.querySelectorAll('[data-rml-draggable="true"]').forEach((n) => {
|
|
105
|
+
n.draggable = !1;
|
|
106
|
+
}), document.addEventListener("mousedown", c, { signal: o }), document.addEventListener("mouseup", d, { signal: o }), document.addEventListener("mousemove", l, { signal: o }), document.addEventListener("mouseleave", d, { signal: o }), document.addEventListener("touchstart", c, { signal: o }), document.addEventListener("touchend", d, { signal: o }), document.addEventListener("touchmove", l, { signal: o });
|
|
107
|
+
}
|
|
108
|
+
unregisterCustomDrag() {
|
|
109
|
+
this._customDragSignal.abort(), this._customDragSignal = new AbortController();
|
|
110
|
+
}
|
|
111
|
+
releaseInput(t) {
|
|
112
|
+
this._strategy.releaseInput(t);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const $ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
116
|
+
__proto__: null,
|
|
117
|
+
DragIn: G
|
|
118
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
119
|
+
export {
|
|
120
|
+
M as R,
|
|
121
|
+
m as a,
|
|
122
|
+
N as b,
|
|
123
|
+
R as c,
|
|
124
|
+
v as d,
|
|
125
|
+
w as e,
|
|
126
|
+
C as f,
|
|
127
|
+
O as g,
|
|
128
|
+
b as h,
|
|
129
|
+
E as i,
|
|
130
|
+
L as j,
|
|
131
|
+
g as k,
|
|
132
|
+
$ as l
|
|
133
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var E=Object.defineProperty,w=(i,t,e)=>t in i?E(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,o=(i,t,e)=>w(i,typeof t!="symbol"?t+"":t,e);class S{constructor(t,e,a,n){o(this,"_mainDomElement"),o(this,"_instance"),o(this,"_mode","website"),o(this,"_viewName","main"),this._instance=t,this._mainDomElement=e,this._mode=a,this._viewName=n}async init(){return Promise.resolve()}}const l="rml-drag-in-styles",$="rml-drag-in-drag-element",h="rml-drag-in-overlay",d="rml-drag-in-drag-ghost",u="rml-drag-in-fade-in",p="rml-drag-in-fade-out",_={DISPLAY_NONE:"rml-display-none"},y=.5,b="250ms",v="forwards",f=`@keyframes ${u} {from{opacity: 0;}to {opacity: ${y};}}`,D=`@keyframes ${p} {from{opacity: ${y};}to {opacity: 0;}}`,L=`${u} ${b} ${v}`,I=`${p} ${b} ${v}`,N="https://res.cloudinary.com/roomle/image/upload/v1729679975/fallback_afpyqr.jpg",x=112,C=112;class U extends S{constructor(t,e,a,n){super(t,e,a,n),o(this,"options",{}),o(this,"_customDragSignal",new AbortController),this._mainDomElement=e,this._injectStyles(),this._initializeDragGhost()}_injectStyles(){if(!document.getElementById(l)){const t=document.createElement("style");t.type="text/css",t.id=l,t.innerHTML=`
|
|
2
|
+
.${_.DISPLAY_NONE}{display:none}
|
|
3
|
+
.${h}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}
|
|
4
|
+
.${d}{position:absolute;top:0;left:0;width:1px;height:1px;z-index:999;pointer-events:none;background-color:transparent;}
|
|
5
|
+
${f}
|
|
6
|
+
${D}
|
|
7
|
+
`,document.head.appendChild(t)}}_initializeDragGhost(){const t=this._mainDomElement.parentNode;let e=t.querySelector("."+d);e||(e=document.createElement("div"),e.classList.add(d),e.innerText=" ",t.appendChild(e))}async init(){if(await super.init(),this._mode==="website"){const{DragInFromWebsiteStrategy:t}=await import("./from-website-DInCYX35.mjs");this._strategy=new t(this._instance,this._mainDomElement,this.options)}else if(this._mode==="custom-view"){const{DragInFromCustomViewStrategy:t}=await import("./from-custom-view-Pim0MOO4.mjs");this._strategy=new t(this._instance,this.options,this._viewName)}else throw new Error("Unsupported mode")}get isDragging(){return this._strategy.isDragging}dragStart(t,e,a="rml_id"){this._strategy.dragStart(t,e,a)}dragUpdate(t){this._strategy.dragUpdate(t)}dragEnd(){this._strategy.dragEnd()}touchStart(t,e,a="rml_id"){this._strategy.touchStart(t,e,a)}touchMove(t){this._strategy.touchMove(t)}touchEnd(){this._strategy.touchEnd()}dispose(){this._strategy.dispose()}beforeUpdateGhost(t){this._strategy.beforeUpdateGhost(t)}registerCustomDrag({customDragStart:t,customDragEnd:e,customDragUpdate:a,beforeUpdateGhost:n}){n&&this._strategy.beforeUpdateGhost(n);const r=this._customDragSignal.signal,m=s=>{s.target.getAttribute("data-rml-draggable")==="true"&&t(s)},g=s=>{this._strategy.releaseInput(s),this._strategy.isDragging&&e(s)},c=s=>{a(s)};document.querySelectorAll('[data-rml-draggable="true"]').forEach(s=>{s.draggable=!1}),document.addEventListener("mousedown",m,{signal:r}),document.addEventListener("mouseup",g,{signal:r}),document.addEventListener("mousemove",c,{signal:r}),document.addEventListener("mouseleave",g,{signal:r}),document.addEventListener("touchstart",m,{signal:r}),document.addEventListener("touchend",g,{signal:r}),document.addEventListener("touchmove",c,{signal:r})}unregisterCustomDrag(){this._customDragSignal.abort(),this._customDragSignal=new AbortController}releaseInput(t){this._strategy.releaseInput(t)}}const j=Object.freeze(Object.defineProperty({__proto__:null,DragIn:U},Symbol.toStringTag,{value:"Module"}));export{$ as R,l as a,f as b,D as c,N as d,x as e,C as f,L as g,I as h,h as i,_ as j,d as k,j as l};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
var O = Object.defineProperty;
|
|
2
|
+
var B = (e, t, s) => t in e ? O(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
+
var i = (e, t, s) => B(e, typeof t != "symbol" ? t + "" : t, s);
|
|
4
|
+
import { C as T, b, e as m, i as y, T as I, c as v, d as L } from "./touch-drag-BsAmrceE.mjs";
|
|
5
|
+
import { d as c, e as Y, f as X } from "./drag-in-3CJWP_Px.mjs";
|
|
6
|
+
const G = (e) => `[data-rml-custom-view="${e}"]`, l = (e) => {
|
|
7
|
+
e.preventDefault(), e.stopPropagation();
|
|
8
|
+
}, w = (e, t, s, r) => {
|
|
9
|
+
const a = s - e, n = r - t;
|
|
10
|
+
return Math.sqrt(a * a + n * n);
|
|
11
|
+
};
|
|
12
|
+
class U {
|
|
13
|
+
constructor({ onCustomDragStart: t }, s = {}) {
|
|
14
|
+
i(this, "_startX", 0);
|
|
15
|
+
i(this, "_startY", 0);
|
|
16
|
+
i(this, "_lastX", 0);
|
|
17
|
+
i(this, "_lastY", 0);
|
|
18
|
+
i(this, "_delay");
|
|
19
|
+
i(this, "_epsilon");
|
|
20
|
+
i(this, "_isStarted", !1);
|
|
21
|
+
i(this, "_isEnded", !1);
|
|
22
|
+
i(this, "_isWaiting", !1);
|
|
23
|
+
i(this, "_onCustomDragStart");
|
|
24
|
+
this._delay = typeof s.delay == "number" ? s.delay : T, this._epsilon = typeof s.epsilon == "number" ? s.epsilon : b, this._onCustomDragStart = t;
|
|
25
|
+
}
|
|
26
|
+
onMove(t) {
|
|
27
|
+
this._lastX = t.clientX, this._lastY = t.clientY, this._isWaiting && w(
|
|
28
|
+
this._startX,
|
|
29
|
+
this._startY,
|
|
30
|
+
this._lastX,
|
|
31
|
+
this._lastY
|
|
32
|
+
) > this._epsilon && (this._onCustomDragStart(t), this._isWaiting = !1);
|
|
33
|
+
}
|
|
34
|
+
onStart(t) {
|
|
35
|
+
this._startX = t.clientX, this._startY = t.clientY, this.onMove(t), this._isWaiting = !0;
|
|
36
|
+
}
|
|
37
|
+
onEnd() {
|
|
38
|
+
this._reset();
|
|
39
|
+
}
|
|
40
|
+
_reset() {
|
|
41
|
+
this._startX = 0, this._startY = 0, this._lastX = 0, this._lastY = 0, this._isWaiting = !1;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const u = "data-rml-old-draggable", R = void 0, f = (e, t) => {
|
|
45
|
+
const s = y(e), r = {
|
|
46
|
+
delay: s ? v : T,
|
|
47
|
+
epsilon: s ? L : b
|
|
48
|
+
};
|
|
49
|
+
if (!t)
|
|
50
|
+
return r;
|
|
51
|
+
if (!s && !(e instanceof MouseEvent))
|
|
52
|
+
return console.warn(
|
|
53
|
+
"Unsupported event! It is not TouchEvent and also not MouseEvent"
|
|
54
|
+
), r;
|
|
55
|
+
const {
|
|
56
|
+
delayKey: a,
|
|
57
|
+
epsilonKey: n
|
|
58
|
+
} = s ? { delayKey: "touchDragDelay", epsilonKey: "touchDragEpsilon" } : { delayKey: "customDragDelay", epsilonKey: "customDragEpsilon" };
|
|
59
|
+
return typeof t[a] == "number" && (r.delay = t.touchDragDelay), typeof t[n] == "number" && (r.epsilon = t.touchDragEpsilon), r;
|
|
60
|
+
}, M = (e) => {
|
|
61
|
+
let t = "", s = Y, r = X;
|
|
62
|
+
if (!e)
|
|
63
|
+
return { url: c, width: s, height: r };
|
|
64
|
+
const a = e;
|
|
65
|
+
if (a instanceof HTMLElement) {
|
|
66
|
+
const n = a.getBoundingClientRect(), o = a.getAttribute("data-rml-ghost-url"), h = a.getAttribute("data-rml-ghost-width"), _ = a.getAttribute("data-rml-ghost-height");
|
|
67
|
+
o ? t = o : !o && a instanceof HTMLImageElement && a.src && (t = a.src), t ? (s = n.width, r = n.height) : t = c, s = h ? parseInt(h, 10) : s, r = _ ? parseInt(_, 10) : r;
|
|
68
|
+
}
|
|
69
|
+
return { url: t || c, width: s, height: r };
|
|
70
|
+
};
|
|
71
|
+
class N {
|
|
72
|
+
constructor(t, s, r) {
|
|
73
|
+
i(this, "_options", {});
|
|
74
|
+
i(this, "_instance");
|
|
75
|
+
i(this, "_viewName");
|
|
76
|
+
i(this, "_currentCustomDrag", null);
|
|
77
|
+
i(this, "_currentBb", null);
|
|
78
|
+
i(this, "_startTarget", null);
|
|
79
|
+
i(this, "_onBeforeUpdateDrag", () => ({}));
|
|
80
|
+
i(this, "isDragging", !1);
|
|
81
|
+
this._instance = t, this._options = s || {}, this._viewName = r;
|
|
82
|
+
}
|
|
83
|
+
beforeUpdateGhost(t) {
|
|
84
|
+
this._onBeforeUpdateDrag = t;
|
|
85
|
+
}
|
|
86
|
+
async _dragStart(t, s, r = "rml_id") {
|
|
87
|
+
this._startTarget && (this._startTarget.style.pointerEvents = "none", this._startTarget.style.userSelect = "none", this._startTarget.setAttribute(
|
|
88
|
+
u,
|
|
89
|
+
this._startTarget.draggable.toString()
|
|
90
|
+
), this._startTarget.draggable = !1, this._startTarget.removeEventListener("dragstart", l), this._startTarget.addEventListener("dragstart", l)), this._currentBb = await this._instance.getBoundingClientRect(
|
|
91
|
+
G(this._viewName)
|
|
92
|
+
);
|
|
93
|
+
const { clientX: a, clientY: n } = m(s), o = this._currentBb.x + a, h = this._currentBb.y + n;
|
|
94
|
+
this.isDragging = !0, this._instance.dragInObject(t, o, h, r);
|
|
95
|
+
}
|
|
96
|
+
_dragUpdate(t) {
|
|
97
|
+
if (document.body.focus(), this._currentCustomDrag && this._currentCustomDrag.onMove(t), !this._currentBb || !this.isDragging)
|
|
98
|
+
return;
|
|
99
|
+
const { clientX: s, clientY: r } = m(t), { url: a, width: n, height: o } = M(this._startTarget), h = this._currentBb.x + s, _ = this._currentBb.y + r, g = this._options || {}, d = {
|
|
100
|
+
ghost: {
|
|
101
|
+
visibleIn: {
|
|
102
|
+
x: this._currentBb.x - (g.dragInOverlapX || 0),
|
|
103
|
+
y: this._currentBb.y + (g.dragInOverlapY || 0),
|
|
104
|
+
width: this._currentBb.width + (g.dragInOverlapX || 0),
|
|
105
|
+
height: this._currentBb.height + (g.dragInOverlapY || 0)
|
|
106
|
+
},
|
|
107
|
+
url: a,
|
|
108
|
+
width: n,
|
|
109
|
+
height: o
|
|
110
|
+
}
|
|
111
|
+
}, {
|
|
112
|
+
x: D,
|
|
113
|
+
y: p,
|
|
114
|
+
options: E
|
|
115
|
+
} = this._onBeforeUpdateDrag(h, _, d), S = typeof D == "number" ? D : h, C = typeof p == "number" ? p : _, A = E || d;
|
|
116
|
+
this._instance.updateDrag(S, C, A);
|
|
117
|
+
}
|
|
118
|
+
_dragEnd() {
|
|
119
|
+
this._currentCustomDrag && this._currentCustomDrag.onEnd(), this._currentCustomDrag = null, this.isDragging = !1, this._currentBb = null, this._resetStartTarget(), this._instance.enableEvents(), this._instance.dragInObjectEnd();
|
|
120
|
+
}
|
|
121
|
+
dragStart(t, s, r) {
|
|
122
|
+
this._instance.disableEvents(), this._startTarget = s.target;
|
|
123
|
+
const a = (n, o) => {
|
|
124
|
+
this._dragStart(t, o, r);
|
|
125
|
+
};
|
|
126
|
+
this._currentCustomDrag = y(s) ? new I(
|
|
127
|
+
R,
|
|
128
|
+
{
|
|
129
|
+
onTouchDragStart: a
|
|
130
|
+
},
|
|
131
|
+
f(s, this._options)
|
|
132
|
+
) : new U(
|
|
133
|
+
{
|
|
134
|
+
onCustomDragStart: (n) => this._dragStart(t, n, r)
|
|
135
|
+
},
|
|
136
|
+
f(s, this._options)
|
|
137
|
+
), this._currentCustomDrag.onStart(s);
|
|
138
|
+
}
|
|
139
|
+
dragEnd() {
|
|
140
|
+
this._dragEnd();
|
|
141
|
+
}
|
|
142
|
+
dragUpdate(t) {
|
|
143
|
+
this._dragUpdate(t);
|
|
144
|
+
}
|
|
145
|
+
touchStart(t, s, r = "rml_id") {
|
|
146
|
+
this.dragStart(t, s, r);
|
|
147
|
+
}
|
|
148
|
+
touchMove(t) {
|
|
149
|
+
this.dragUpdate(t);
|
|
150
|
+
}
|
|
151
|
+
touchEnd() {
|
|
152
|
+
this.dragEnd();
|
|
153
|
+
}
|
|
154
|
+
dispose() {
|
|
155
|
+
}
|
|
156
|
+
_resetStartTarget() {
|
|
157
|
+
this._startTarget && (this._startTarget.style.pointerEvents = "", this._startTarget.style.userSelect = "", this._startTarget.draggable = this._startTarget.getAttribute(u) === "true", this._startTarget.removeAttribute(u), this._startTarget.removeEventListener("dragstart", l));
|
|
158
|
+
}
|
|
159
|
+
releaseInput(t) {
|
|
160
|
+
this._currentCustomDrag && this._currentCustomDrag.onEnd(), this._resetStartTarget();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
export {
|
|
164
|
+
N as DragInFromCustomViewStrategy
|
|
165
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var w=Object.defineProperty,B=(e,t,s)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,i=(e,t,s)=>B(e,typeof t!="symbol"?t+"":t,s);import{C as b,b as y,e as D,i as v,T as X,c as Y,d as I}from"./touch-drag-DibgNiRO.mjs";import{d as l,e as M,f as U}from"./drag-in-sE43chRN.mjs";const O=e=>`[data-rml-custom-view="${e}"]`,u=e=>{e.preventDefault(),e.stopPropagation()},A=(e,t,s,r)=>{const a=s-e,n=r-t;return Math.sqrt(a*a+n*n)};class x{constructor({onCustomDragStart:t},s={}){i(this,"_startX",0),i(this,"_startY",0),i(this,"_lastX",0),i(this,"_lastY",0),i(this,"_delay"),i(this,"_epsilon"),i(this,"_isStarted",!1),i(this,"_isEnded",!1),i(this,"_isWaiting",!1),i(this,"_onCustomDragStart"),this._delay=typeof s.delay=="number"?s.delay:b,this._epsilon=typeof s.epsilon=="number"?s.epsilon:y,this._onCustomDragStart=t}onMove(t){this._lastX=t.clientX,this._lastY=t.clientY,this._isWaiting&&A(this._startX,this._startY,this._lastX,this._lastY)>this._epsilon&&(this._onCustomDragStart(t),this._isWaiting=!1)}onStart(t){this._startX=t.clientX,this._startY=t.clientY,this.onMove(t),this._isWaiting=!0}onEnd(){this._reset()}_reset(){this._startX=0,this._startY=0,this._lastX=0,this._lastY=0,this._isWaiting=!1}}const d="data-rml-old-draggable",K=void 0,f=(e,t)=>{const s=v(e),r={delay:s?Y:b,epsilon:s?I:y};if(!t)return r;if(!s&&!(e instanceof MouseEvent))return console.warn("Unsupported event! It is not TouchEvent and also not MouseEvent"),r;const{delayKey:a,epsilonKey:n}=s?{delayKey:"touchDragDelay",epsilonKey:"touchDragEpsilon"}:{delayKey:"customDragDelay",epsilonKey:"customDragEpsilon"};return typeof t[a]=="number"&&(r.delay=t.touchDragDelay),typeof t[n]=="number"&&(r.epsilon=t.touchDragEpsilon),r},L=e=>{let t="",s=M,r=U;if(!e)return{url:l,width:s,height:r};const a=e;if(a instanceof HTMLElement){const n=a.getBoundingClientRect(),h=a.getAttribute("data-rml-ghost-url"),o=a.getAttribute("data-rml-ghost-width"),g=a.getAttribute("data-rml-ghost-height");h?t=h:!h&&a instanceof HTMLImageElement&&a.src&&(t=a.src),t?(s=n.width,r=n.height):t=l,s=o?parseInt(o,10):s,r=g?parseInt(g,10):r}return{url:t||l,width:s,height:r}};class W{constructor(t,s,r){i(this,"_options",{}),i(this,"_instance"),i(this,"_viewName"),i(this,"_currentCustomDrag",null),i(this,"_currentBb",null),i(this,"_startTarget",null),i(this,"_onBeforeUpdateDrag",()=>({})),i(this,"isDragging",!1),this._instance=t,this._options=s||{},this._viewName=r}beforeUpdateGhost(t){this._onBeforeUpdateDrag=t}async _dragStart(t,s,r="rml_id"){this._startTarget&&(this._startTarget.style.pointerEvents="none",this._startTarget.style.userSelect="none",this._startTarget.setAttribute(d,this._startTarget.draggable.toString()),this._startTarget.draggable=!1,this._startTarget.removeEventListener("dragstart",u),this._startTarget.addEventListener("dragstart",u)),this._currentBb=await this._instance.getBoundingClientRect(O(this._viewName));const{clientX:a,clientY:n}=D(s),h=this._currentBb.x+a,o=this._currentBb.y+n;this.isDragging=!0,this._instance.dragInObject(t,h,o,r)}_dragUpdate(t){if(document.body.focus(),this._currentCustomDrag&&this._currentCustomDrag.onMove(t),!this._currentBb||!this.isDragging)return;const{clientX:s,clientY:r}=D(t),{url:a,width:n,height:h}=L(this._startTarget),o=this._currentBb.x+s,g=this._currentBb.y+r,_=this._options||{},c={ghost:{visibleIn:{x:this._currentBb.x-(_.dragInOverlapX||0),y:this._currentBb.y+(_.dragInOverlapY||0),width:this._currentBb.width+(_.dragInOverlapX||0),height:this._currentBb.height+(_.dragInOverlapY||0)},url:a,width:n,height:h}},{x:p,y:m,options:T}=this._onBeforeUpdateDrag(o,g,c),E=typeof p=="number"?p:o,S=typeof m=="number"?m:g,C=T||c;this._instance.updateDrag(E,S,C)}_dragEnd(){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._currentCustomDrag=null,this.isDragging=!1,this._currentBb=null,this._resetStartTarget(),this._instance.enableEvents(),this._instance.dragInObjectEnd()}dragStart(t,s,r){this._instance.disableEvents(),this._startTarget=s.target;const a=(n,h)=>{this._dragStart(t,h,r)};this._currentCustomDrag=v(s)?new X(K,{onTouchDragStart:a},f(s,this._options)):new x({onCustomDragStart:n=>this._dragStart(t,n,r)},f(s,this._options)),this._currentCustomDrag.onStart(s)}dragEnd(){this._dragEnd()}dragUpdate(t){this._dragUpdate(t)}touchStart(t,s,r="rml_id"){this.dragStart(t,s,r)}touchMove(t){this.dragUpdate(t)}touchEnd(){this.dragEnd()}dispose(){}_resetStartTarget(){this._startTarget&&(this._startTarget.style.pointerEvents="",this._startTarget.style.userSelect="",this._startTarget.draggable=this._startTarget.getAttribute(d)==="true",this._startTarget.removeAttribute(d),this._startTarget.removeEventListener("dragstart",u))}releaseInput(t){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._resetStartTarget()}}export{W as DragInFromCustomViewStrategy};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
var b = Object.defineProperty;
|
|
2
|
+
var F = (o, t, e) => t in o ? b(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var g = (o, t, e) => F(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { g as M, e as A, a as p, i as C, T as N } from "./touch-drag-BsAmrceE.mjs";
|
|
5
|
+
import { R as m, a as G, b as O, c as w, d as Y, e as S, f as R, g as I, h as E, i as y, j as x, k as B } from "./drag-in-3CJWP_Px.mjs";
|
|
6
|
+
const T = (o, t, e = 0, n = 0) => {
|
|
7
|
+
const a = t.x + t.width + e, i = t.x - e, s = t.y + t.height + n, h = t.y - n, { x: l, y: r } = o;
|
|
8
|
+
return l >= i && l <= a && r >= h && r <= s;
|
|
9
|
+
}, H = () => {
|
|
10
|
+
if (!!!document.getElementById(G)) {
|
|
11
|
+
const t = document.createElement("style");
|
|
12
|
+
t.type = "text/css", t.id = G, t.innerHTML = `
|
|
13
|
+
${O}
|
|
14
|
+
${w}
|
|
15
|
+
`, document.head.appendChild(t);
|
|
16
|
+
}
|
|
17
|
+
}, P = ({ x: o, y: t }, e, n) => {
|
|
18
|
+
var i, s, h, l;
|
|
19
|
+
let a = document.getElementById(m);
|
|
20
|
+
if (!a) {
|
|
21
|
+
if (a = document.createElement("div"), (i = e.ghost) != null && i.element)
|
|
22
|
+
a.appendChild(e.ghost.element);
|
|
23
|
+
else {
|
|
24
|
+
const r = document.createElement("img");
|
|
25
|
+
r.src = ((s = e.ghost) == null ? void 0 : s.url) || Y, r.width = ((h = e.ghost) == null ? void 0 : h.width) || S, r.height = ((l = e.ghost) == null ? void 0 : l.height) || R, a.appendChild(r);
|
|
26
|
+
}
|
|
27
|
+
a.id = m, a.style.position = "fixed", a.style.top = "0", a.style.left = "0", a.style.willChange = "transform", a.style.transform = "translate3d(0, 0, 0)", a.style.zIndex = "9999", a.style.opacity = "0.5", e.ghost && e.ghost.visibleIn && !T(
|
|
28
|
+
{ x: o, y: t },
|
|
29
|
+
e.ghost.visibleIn,
|
|
30
|
+
n.dragInOverlapX,
|
|
31
|
+
n.dragInOverlapY
|
|
32
|
+
) && (a.style.display = "none"), a.style.pointerEvents = "none", document.body.appendChild(a);
|
|
33
|
+
}
|
|
34
|
+
}, U = ({ x: o, y: t }, e, n) => {
|
|
35
|
+
var r, d;
|
|
36
|
+
const a = document.getElementById(m);
|
|
37
|
+
if (!a)
|
|
38
|
+
return;
|
|
39
|
+
let i = (r = e.ghost) == null ? void 0 : r.width, s = (d = e.ghost) == null ? void 0 : d.height;
|
|
40
|
+
typeof i > "u" && (i = a.getBoundingClientRect().width || S), typeof s > "u" && (s = a.getBoundingClientRect().height || R);
|
|
41
|
+
const h = o - i / 2, l = t - s / 2;
|
|
42
|
+
a.style.transform = `translate3d(${h}px, ${l}px, 0)`, e.ghost && (!e.ghost.visibleIn || // user didn't specify were to show the drag ghost, therefore we assume that we should show it always
|
|
43
|
+
T(
|
|
44
|
+
{ x: o, y: t },
|
|
45
|
+
e.ghost.visibleIn,
|
|
46
|
+
n.dragInOverlapX,
|
|
47
|
+
n.dragInOverlapY
|
|
48
|
+
) ? a.style.animation != I && (a.style.animation = I) : a.style.animation != E && (a.style.animation = E));
|
|
49
|
+
};
|
|
50
|
+
class X {
|
|
51
|
+
constructor(t = null) {
|
|
52
|
+
g(this, "_dragGhostAnimationFrameId", null);
|
|
53
|
+
g(this, "_dragGhostRemoveAnimationFrameId", null);
|
|
54
|
+
g(this, "_dragGhostElement", null);
|
|
55
|
+
this._dragGhostElement = t;
|
|
56
|
+
}
|
|
57
|
+
updateDragGhost(t, e, n = {}, a = {}) {
|
|
58
|
+
var i;
|
|
59
|
+
this._dragGhostRemoveAnimationFrameId && (cancelAnimationFrame(this._dragGhostRemoveAnimationFrameId), this._dragGhostRemoveAnimationFrameId = null), !((i = n.ghost) != null && i.external) && n.ghost && (this._dragGhostAnimationFrameId || (this._dragGhostAnimationFrameId = requestAnimationFrame(() => {
|
|
60
|
+
H();
|
|
61
|
+
const s = { x: t, y: e };
|
|
62
|
+
!n.ghost && this._dragGhostElement && (n.ghost = {}), n.ghost && !n.ghost.element && this._dragGhostElement && (n.ghost.element = this._dragGhostElement), P(s, n, a), U(s, n, a), this._dragGhostAnimationFrameId = null;
|
|
63
|
+
})));
|
|
64
|
+
}
|
|
65
|
+
removeDragGhost() {
|
|
66
|
+
this._dragGhostAnimationFrameId && (cancelAnimationFrame(this._dragGhostAnimationFrameId), this._dragGhostAnimationFrameId = null), this._dragGhostRemoveAnimationFrameId || (this._dragGhostRemoveAnimationFrameId = requestAnimationFrame(() => {
|
|
67
|
+
const t = document.getElementById(m);
|
|
68
|
+
t && document.body.removeChild(t), this._dragGhostRemoveAnimationFrameId = null;
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
class j {
|
|
73
|
+
constructor(t, e, n) {
|
|
74
|
+
g(this, "_options", {});
|
|
75
|
+
g(this, "_instance");
|
|
76
|
+
g(this, "_mainDomElement");
|
|
77
|
+
g(this, "_currentDrag", {});
|
|
78
|
+
g(this, "_currentTouch", null);
|
|
79
|
+
g(this, "_firefoxDragPosition", { x: 0, y: 0 });
|
|
80
|
+
g(this, "_onBeforeUpdateDrag", () => ({}));
|
|
81
|
+
g(this, "isDragging", !1);
|
|
82
|
+
g(this, "_firefoxFallback", (t) => {
|
|
83
|
+
if (!this._currentDrag.event)
|
|
84
|
+
return;
|
|
85
|
+
const e = t || window.event;
|
|
86
|
+
this._firefoxDragPosition.x = e.pageX || 0, this._firefoxDragPosition.y = e.pageY || 0;
|
|
87
|
+
});
|
|
88
|
+
this._instance = t, this._mainDomElement = e, this._options = n || {}, this._firefoxFallback = this._firefoxFallback.bind(this), document.addEventListener("dragover", this._firefoxFallback);
|
|
89
|
+
}
|
|
90
|
+
beforeUpdateGhost(t) {
|
|
91
|
+
this._onBeforeUpdateDrag = t;
|
|
92
|
+
}
|
|
93
|
+
dragStart(t, e, n = "rml_id") {
|
|
94
|
+
const a = this._mainDomElement.parentNode;
|
|
95
|
+
if (M(a).position !== "relative") {
|
|
96
|
+
console.warn(
|
|
97
|
+
"Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly"
|
|
98
|
+
);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this._mainDomElement.style.pointerEvents = "none";
|
|
102
|
+
let s = a.querySelector(
|
|
103
|
+
"." + y
|
|
104
|
+
);
|
|
105
|
+
s || (s = document.createElement("div"), s.classList.add(y), a.appendChild(s)), s.classList.remove(x.DISPLAY_NONE), e.target.getAttribute("draggable") || console.warn(
|
|
106
|
+
`Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`
|
|
107
|
+
);
|
|
108
|
+
const l = a.querySelector(
|
|
109
|
+
"." + B
|
|
110
|
+
);
|
|
111
|
+
this._currentDrag.event = e;
|
|
112
|
+
const r = e.target, d = r.cloneNode(), c = r.getBoundingClientRect();
|
|
113
|
+
d.style.width = `${c.width}px`, d.style.height = `${c.height}px`, this._currentDrag.ghost = new X(d), this._currentDrag.offset || (this._currentDrag.offset = { x: 0, y: 0 });
|
|
114
|
+
const { clientX: u, clientY: f } = A(
|
|
115
|
+
e,
|
|
116
|
+
this._firefoxDragPosition
|
|
117
|
+
);
|
|
118
|
+
this._currentDrag.offset.x = u - c.left, this._currentDrag.offset.y = f - c.top, e instanceof DragEvent && e.dataTransfer && e.dataTransfer.setDragImage && e.dataTransfer.setDragImage(l, 0, 0);
|
|
119
|
+
const { x: _, y: D } = p(
|
|
120
|
+
a,
|
|
121
|
+
this._currentDrag.event || e,
|
|
122
|
+
this._firefoxDragPosition
|
|
123
|
+
), v = Math.max(1, _), L = Math.max(1, D);
|
|
124
|
+
this.isDragging = !0, this._instance.dragInObject(t, v, L, n);
|
|
125
|
+
}
|
|
126
|
+
dragUpdate(t) {
|
|
127
|
+
const e = this._mainDomElement.parentNode, { x: n, y: a } = p(e, t, this._firefoxDragPosition);
|
|
128
|
+
if (n === 0 && a === 0)
|
|
129
|
+
return;
|
|
130
|
+
const i = Math.max(1, n), s = Math.max(1, a);
|
|
131
|
+
if (i === 1 && s === 1)
|
|
132
|
+
return;
|
|
133
|
+
let h = i, l = s;
|
|
134
|
+
if (C(t)) {
|
|
135
|
+
const _ = this._options.fingerSize || 0;
|
|
136
|
+
h = Math.max(2, i + _), l = Math.max(2, s - _);
|
|
137
|
+
}
|
|
138
|
+
const {
|
|
139
|
+
x: r,
|
|
140
|
+
y: d,
|
|
141
|
+
options: c
|
|
142
|
+
} = this._onBeforeUpdateDrag(h, l, {}), u = typeof r == "number" ? r : h, f = typeof d == "number" ? d : l;
|
|
143
|
+
if (this._currentDrag.ghost) {
|
|
144
|
+
const { clientX: _, clientY: D } = A(
|
|
145
|
+
t,
|
|
146
|
+
this._firefoxDragPosition
|
|
147
|
+
);
|
|
148
|
+
console.log("dragin", "dragupdate is here: ", location.href), this._currentDrag.ghost.updateDragGhost(
|
|
149
|
+
_,
|
|
150
|
+
D,
|
|
151
|
+
c || {},
|
|
152
|
+
this._options || {}
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
this._instance.updateDrag(u, f, {});
|
|
156
|
+
}
|
|
157
|
+
dragEnd() {
|
|
158
|
+
this._mainDomElement.style.pointerEvents = "all";
|
|
159
|
+
const t = this._mainDomElement.parentNode;
|
|
160
|
+
this.isDragging = !1, this._instance.dragInObjectEnd(), this._currentDrag.ghost && (this._currentDrag.ghost.removeDragGhost(), this._currentDrag.ghost = null), this._currentDrag = {}, this._firefoxDragPosition = { x: 0, y: 0 };
|
|
161
|
+
const e = t.querySelector(
|
|
162
|
+
"." + y
|
|
163
|
+
);
|
|
164
|
+
e && e.classList.add(x.DISPLAY_NONE);
|
|
165
|
+
}
|
|
166
|
+
touchStart(t, e, n = "rml_id") {
|
|
167
|
+
var s, h;
|
|
168
|
+
e.preventDefault();
|
|
169
|
+
const a = (l, r) => {
|
|
170
|
+
this.dragStart(t, r, n);
|
|
171
|
+
}, i = {};
|
|
172
|
+
typeof ((s = this._options) == null ? void 0 : s.touchDragDelay) == "number" && (i.delay = this._options.touchDragDelay), (h = this._options) != null && h.touchDragEpsilon && (i.epsilon = this._options.touchDragEpsilon), this._currentTouch = new N(
|
|
173
|
+
void 0,
|
|
174
|
+
{
|
|
175
|
+
onTouchDragStart: a
|
|
176
|
+
},
|
|
177
|
+
i
|
|
178
|
+
), this._currentTouch.onStart(e);
|
|
179
|
+
}
|
|
180
|
+
touchMove(t) {
|
|
181
|
+
this._currentTouch && this._currentTouch.onMove(t), this._currentDrag.event && this.dragUpdate(t);
|
|
182
|
+
}
|
|
183
|
+
touchEnd() {
|
|
184
|
+
this._currentTouch && this._currentTouch.onEnd(), this._currentTouch = null, this.dragEnd();
|
|
185
|
+
}
|
|
186
|
+
dispose() {
|
|
187
|
+
document.removeEventListener("dragover", this._firefoxFallback);
|
|
188
|
+
}
|
|
189
|
+
releaseInput(t) {
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
export {
|
|
193
|
+
j as DragInFromWebsiteStrategy
|
|
194
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var w=Object.defineProperty,T=(r,t,e)=>t in r?w(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,d=(r,t,e)=>T(r,typeof t!="symbol"?t+"":t,e);import{g as S,e as D,a as v,i as P,T as R}from"./touch-drag-DibgNiRO.mjs";import{R as m,a as x,b as B,c as C,d as M,e as I,f as E,g as b,h as F,i as y,j as G,k as O}from"./drag-in-sE43chRN.mjs";const A=(r,t,e=0,n=0)=>{const a=t.x+t.width+e,s=t.x-e,o=t.y+t.height+n,h=t.y-n,{x:i,y:l}=r;return i>=s&&i<=a&&l>=h&&l<=o},L=()=>{if(!document.getElementById(x)){const r=document.createElement("style");r.type="text/css",r.id=x,r.innerHTML=`
|
|
2
|
+
${B}
|
|
3
|
+
${C}
|
|
4
|
+
`,document.head.appendChild(r)}},N=({x:r,y:t},e,n)=>{var a,s,o,h;let i=document.getElementById(m);if(!i){if(i=document.createElement("div"),(a=e.ghost)!=null&&a.element)i.appendChild(e.ghost.element);else{const l=document.createElement("img");l.src=((s=e.ghost)==null?void 0:s.url)||M,l.width=((o=e.ghost)==null?void 0:o.width)||I,l.height=((h=e.ghost)==null?void 0:h.height)||E,i.appendChild(l)}i.id=m,i.style.position="fixed",i.style.top="0",i.style.left="0",i.style.willChange="transform",i.style.transform="translate3d(0, 0, 0)",i.style.zIndex="9999",i.style.opacity="0.5",e.ghost&&e.ghost.visibleIn&&!A({x:r,y:t},e.ghost.visibleIn,n.dragInOverlapX,n.dragInOverlapY)&&(i.style.display="none"),i.style.pointerEvents="none",document.body.appendChild(i)}},Y=({x:r,y:t},e,n)=>{var a,s;const o=document.getElementById(m);if(!o)return;let h=(a=e.ghost)==null?void 0:a.width,i=(s=e.ghost)==null?void 0:s.height;typeof h>"u"&&(h=o.getBoundingClientRect().width||I),typeof i>"u"&&(i=o.getBoundingClientRect().height||E);const l=r-h/2,g=t-i/2;o.style.transform=`translate3d(${l}px, ${g}px, 0)`,e.ghost&&(!e.ghost.visibleIn||A({x:r,y:t},e.ghost.visibleIn,n.dragInOverlapX,n.dragInOverlapY)?o.style.animation!=b&&(o.style.animation=b):o.style.animation!=F&&(o.style.animation=F))};class U{constructor(t=null){d(this,"_dragGhostAnimationFrameId",null),d(this,"_dragGhostRemoveAnimationFrameId",null),d(this,"_dragGhostElement",null),this._dragGhostElement=t}updateDragGhost(t,e,n={},a={}){var s;this._dragGhostRemoveAnimationFrameId&&(cancelAnimationFrame(this._dragGhostRemoveAnimationFrameId),this._dragGhostRemoveAnimationFrameId=null),!((s=n.ghost)!=null&&s.external)&&n.ghost&&(this._dragGhostAnimationFrameId||(this._dragGhostAnimationFrameId=requestAnimationFrame(()=>{L();const o={x:t,y:e};!n.ghost&&this._dragGhostElement&&(n.ghost={}),n.ghost&&!n.ghost.element&&this._dragGhostElement&&(n.ghost.element=this._dragGhostElement),N(o,n,a),Y(o,n,a),this._dragGhostAnimationFrameId=null})))}removeDragGhost(){this._dragGhostAnimationFrameId&&(cancelAnimationFrame(this._dragGhostAnimationFrameId),this._dragGhostAnimationFrameId=null),this._dragGhostRemoveAnimationFrameId||(this._dragGhostRemoveAnimationFrameId=requestAnimationFrame(()=>{const t=document.getElementById(m);t&&document.body.removeChild(t),this._dragGhostRemoveAnimationFrameId=null}))}}class k{constructor(t,e,n){d(this,"_options",{}),d(this,"_instance"),d(this,"_mainDomElement"),d(this,"_currentDrag",{}),d(this,"_currentTouch",null),d(this,"_firefoxDragPosition",{x:0,y:0}),d(this,"_onBeforeUpdateDrag",()=>({})),d(this,"isDragging",!1),d(this,"_firefoxFallback",a=>{if(!this._currentDrag.event)return;const s=a||window.event;this._firefoxDragPosition.x=s.pageX||0,this._firefoxDragPosition.y=s.pageY||0}),this._instance=t,this._mainDomElement=e,this._options=n||{},this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback)}beforeUpdateGhost(t){this._onBeforeUpdateDrag=t}dragStart(t,e,n="rml_id"){const a=this._mainDomElement.parentNode;if(S(a).position!=="relative"){console.warn("Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly");return}this._mainDomElement.style.pointerEvents="none";let s=a.querySelector("."+y);s||(s=document.createElement("div"),s.classList.add(y),a.appendChild(s)),s.classList.remove(G.DISPLAY_NONE),e.target.getAttribute("draggable")||console.warn(`Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`);const o=a.querySelector("."+O);this._currentDrag.event=e;const h=e.target,i=h.cloneNode(),l=h.getBoundingClientRect();i.style.width=`${l.width}px`,i.style.height=`${l.height}px`,this._currentDrag.ghost=new U(i),this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:g,clientY:u}=D(e,this._firefoxDragPosition);this._currentDrag.offset.x=g-l.left,this._currentDrag.offset.y=u-l.top,e instanceof DragEvent&&e.dataTransfer&&e.dataTransfer.setDragImage&&e.dataTransfer.setDragImage(o,0,0);const{x:_,y:f}=v(a,this._currentDrag.event||e,this._firefoxDragPosition),c=Math.max(1,_),p=Math.max(1,f);this.isDragging=!0,this._instance.dragInObject(t,c,p,n)}dragUpdate(t){const e=this._mainDomElement.parentNode,{x:n,y:a}=v(e,t,this._firefoxDragPosition);if(n===0&&a===0)return;const s=Math.max(1,n),o=Math.max(1,a);if(s===1&&o===1)return;let h=s,i=o;if(P(t)){const c=this._options.fingerSize||0;h=Math.max(2,s+c),i=Math.max(2,o-c)}const{x:l,y:g,options:u}=this._onBeforeUpdateDrag(h,i,{}),_=typeof l=="number"?l:h,f=typeof g=="number"?g:i;if(this._currentDrag.ghost){const{clientX:c,clientY:p}=D(t,this._firefoxDragPosition);console.log("dragin","dragupdate is here: ",location.href),this._currentDrag.ghost.updateDragGhost(c,p,u||{},this._options||{})}this._instance.updateDrag(_,f,{})}dragEnd(){this._mainDomElement.style.pointerEvents="all";const t=this._mainDomElement.parentNode;this.isDragging=!1,this._instance.dragInObjectEnd(),this._currentDrag.ghost&&(this._currentDrag.ghost.removeDragGhost(),this._currentDrag.ghost=null),this._currentDrag={},this._firefoxDragPosition={x:0,y:0};const e=t.querySelector("."+y);e&&e.classList.add(G.DISPLAY_NONE)}touchStart(t,e,n="rml_id"){var a,s;e.preventDefault();const o=(i,l)=>{this.dragStart(t,l,n)},h={};typeof((a=this._options)==null?void 0:a.touchDragDelay)=="number"&&(h.delay=this._options.touchDragDelay),(s=this._options)!=null&&s.touchDragEpsilon&&(h.epsilon=this._options.touchDragEpsilon),this._currentTouch=new R(void 0,{onTouchDragStart:o},h),this._currentTouch.onStart(e)}touchMove(t){this._currentTouch&&this._currentTouch.onMove(t),this._currentDrag.event&&this.dragUpdate(t)}touchEnd(){this._currentTouch&&this._currentTouch.onEnd(),this._currentTouch=null,this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}releaseInput(t){}}export{k as DragInFromWebsiteStrategy};
|