@roomle/embedding-lib 5.5.0 → 5.6.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 +34 -12
- package/drag-in-BZZo-kSu.mjs +513 -0
- package/drag-in-Buavf-ZW.mjs +7 -0
- package/index.d.ts +104 -40
- package/package.json +2 -2
- package/roomle-embedding-lib.es.js +353 -278
- package/roomle-embedding-lib.es.min.js +8 -8
- package/roomle-embedding-lib.umd.js +12 -12
- package/roomle-embedding-lib.umd.min.js +13 -13
- package/drag-in-BKrnFtmJ.mjs +0 -7
- package/drag-in-DC-05b4s.mjs +0 -265
package/drag-in-DC-05b4s.mjs
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
var v = Object.defineProperty;
|
|
2
|
-
var P = (n, t, e) => t in n ? v(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
-
var c = (n, t, e) => P(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
class $ {
|
|
5
|
-
constructor(t = 16) {
|
|
6
|
-
c(this, "_computedStyleCache", /* @__PURE__ */ new Map());
|
|
7
|
-
c(this, "_maxLifetime", 16);
|
|
8
|
-
c(this, "_cacheCleanInterval", null);
|
|
9
|
-
this._maxLifetime = t;
|
|
10
|
-
}
|
|
11
|
-
get(t) {
|
|
12
|
-
const e = this._computedStyleCache.get(t), i = Date.now();
|
|
13
|
-
if (e && i - e.updated < this._maxLifetime)
|
|
14
|
-
return e.style;
|
|
15
|
-
const s = getComputedStyle(t);
|
|
16
|
-
return this._computedStyleCache.set(t, { style: s, updated: i }), this._cacheCleanInterval || (this._cacheCleanInterval = setInterval(
|
|
17
|
-
() => this._cleanUpCache,
|
|
18
|
-
Math.max(this._maxLifetime * 1e3, 5e3)
|
|
19
|
-
)), s;
|
|
20
|
-
}
|
|
21
|
-
_cleanUpCache() {
|
|
22
|
-
const t = Date.now();
|
|
23
|
-
for (const [e, { updated: i }] of this._computedStyleCache.entries())
|
|
24
|
-
t - i >= this._maxLifetime && this._computedStyleCache.delete(e);
|
|
25
|
-
this._computedStyleCache.size === 0 && this._cacheCleanInterval && (clearInterval(this._cacheCleanInterval), this._cacheCleanInterval = null);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const M = (n) => window.TouchEvent && n instanceof window.TouchEvent;
|
|
29
|
-
let D;
|
|
30
|
-
const p = (n) => (D || (D = new $()), D.get(n)), C = (n, t, e) => {
|
|
31
|
-
const i = parseFloat(n), s = window.devicePixelRatio || 1;
|
|
32
|
-
if (t === "px")
|
|
33
|
-
return i;
|
|
34
|
-
if (t === "%") {
|
|
35
|
-
const o = e === document.documentElement ? window.innerWidth : e.offsetWidth;
|
|
36
|
-
return i / 100 * o;
|
|
37
|
-
}
|
|
38
|
-
if (t === "rem") {
|
|
39
|
-
const o = parseFloat(
|
|
40
|
-
p(document.documentElement).fontSize
|
|
41
|
-
);
|
|
42
|
-
return i * o;
|
|
43
|
-
}
|
|
44
|
-
if (t === "em") {
|
|
45
|
-
const o = parseFloat(
|
|
46
|
-
p(e).fontSize
|
|
47
|
-
);
|
|
48
|
-
return i * o;
|
|
49
|
-
}
|
|
50
|
-
if (t === "vh" || t === "vw" || t === "vmin" || t === "vmax") {
|
|
51
|
-
const o = {
|
|
52
|
-
vh: window.innerHeight,
|
|
53
|
-
vw: window.innerWidth,
|
|
54
|
-
vmin: Math.min(window.innerWidth, window.innerHeight),
|
|
55
|
-
vmax: Math.max(window.innerWidth, window.innerHeight)
|
|
56
|
-
};
|
|
57
|
-
return i / 100 * o[t];
|
|
58
|
-
}
|
|
59
|
-
const r = {
|
|
60
|
-
cm: 37.7952755906,
|
|
61
|
-
mm: 3.77952755906,
|
|
62
|
-
in: 96
|
|
63
|
-
};
|
|
64
|
-
return t in r ? i * r[t] * s : (console.warn("Unable to determine coordinates for drag-in. Therefore drag-in is not possible. Check the CSS that positions the iframe of Roomle"), 0);
|
|
65
|
-
}, A = (n, t, e = { x: 0, y: 0 }) => {
|
|
66
|
-
const i = n.getBoundingClientRect(), r = p(n).transform;
|
|
67
|
-
let o = 0, l = 0;
|
|
68
|
-
if (r !== "none") {
|
|
69
|
-
const f = /translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/, d = r.match(f);
|
|
70
|
-
d && (o = C(d[1], d[2], n), l = C(d[3], d[4], n));
|
|
71
|
-
}
|
|
72
|
-
const { clientX: _, clientY: a } = w(t, e), h = _ - i.left - o + n.scrollLeft, u = a - i.top - l + n.scrollTop;
|
|
73
|
-
return { x: h, y: u };
|
|
74
|
-
}, w = (n, t) => {
|
|
75
|
-
const { clientX: e, clientY: i } = M(n) ? G(n) : n, s = e || t.x, r = i || t.y;
|
|
76
|
-
return { clientX: s, clientY: r };
|
|
77
|
-
}, G = (n) => {
|
|
78
|
-
if (n.touches.length) {
|
|
79
|
-
let { clientX: e, clientY: i } = n.touches[0];
|
|
80
|
-
if (n.touches.length > 1) {
|
|
81
|
-
const s = n.touches[1], r = s.clientX, o = s.clientY;
|
|
82
|
-
e = (e + r) / 2, i = (i + o) / 2;
|
|
83
|
-
}
|
|
84
|
-
return { clientX: e, clientY: i };
|
|
85
|
-
}
|
|
86
|
-
const t = n.changedTouches[0];
|
|
87
|
-
return { clientX: t.clientX, clientY: t.clientY };
|
|
88
|
-
}, N = 500, L = 10;
|
|
89
|
-
class z {
|
|
90
|
-
constructor(t, { onTouchDragStart: e }, i = {}) {
|
|
91
|
-
c(this, "_touchDragTimeOut");
|
|
92
|
-
c(this, "_onTouchDragStart");
|
|
93
|
-
c(this, "_payload", null);
|
|
94
|
-
c(this, "_delay", N);
|
|
95
|
-
c(this, "_firstTouch", null);
|
|
96
|
-
c(this, "_lastTouch", null);
|
|
97
|
-
c(this, "_epsilon", L);
|
|
98
|
-
this._payload = t, this._onTouchDragStart = e, this._delay = i.delay || N, this._epsilon = i.epsilon || L;
|
|
99
|
-
}
|
|
100
|
-
onTouchStart(t) {
|
|
101
|
-
var e;
|
|
102
|
-
!t || !((e = t == null ? void 0 : t.touches) != null && e.length) || this._touchDragTimeOut || (this._firstTouch = t.touches[t.touches.length - 1], this._touchDragTimeOut = setTimeout(() => {
|
|
103
|
-
this._clearTimeout(), this._lastTouch || (this._lastTouch = t.touches[0]), this._checkXDistance(t)();
|
|
104
|
-
}, this._delay));
|
|
105
|
-
}
|
|
106
|
-
onTouchEnd() {
|
|
107
|
-
this._resetTouches();
|
|
108
|
-
}
|
|
109
|
-
onTouchMove(t) {
|
|
110
|
-
var e;
|
|
111
|
-
!t || !((e = t == null ? void 0 : t.touches) != null && e.length) || (this._lastTouch = t.touches[0]);
|
|
112
|
-
}
|
|
113
|
-
_clearTimeout() {
|
|
114
|
-
this._touchDragTimeOut && (clearTimeout(this._touchDragTimeOut), this._touchDragTimeOut = null);
|
|
115
|
-
}
|
|
116
|
-
_resetTouches() {
|
|
117
|
-
this._clearTimeout(), this._lastTouch = null, this._firstTouch = null, this._payload = null;
|
|
118
|
-
}
|
|
119
|
-
_checkXDistance(t) {
|
|
120
|
-
return () => {
|
|
121
|
-
if (!this._firstTouch || !this._lastTouch)
|
|
122
|
-
return;
|
|
123
|
-
let e = !1;
|
|
124
|
-
e = Math.abs(
|
|
125
|
-
this._firstTouch.clientX - this._lastTouch.clientX
|
|
126
|
-
) < this._epsilon, e && (this._onTouchDragStart(this._payload, t), this._resetTouches());
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
const O = "rml-drag-in-styles", F = "rml-drag-in-drag-element", g = "rml-drag-in-overlay", m = "rml-drag-in-drag-ghost", T = "rml-drag-in-fade-in", b = "rml-drag-in-fade-out", x = {
|
|
131
|
-
DISPLAY_NONE: "rml-display-none"
|
|
132
|
-
}, Y = 0.5, S = "250ms", I = "forwards", E = (n) => n ? !0 : (console.warn("No instance set, cancel drag-in"), !1);
|
|
133
|
-
class U {
|
|
134
|
-
constructor(t) {
|
|
135
|
-
c(this, "_iframe");
|
|
136
|
-
c(this, "_currentDrag", {});
|
|
137
|
-
c(this, "_currentTouch", null);
|
|
138
|
-
c(this, "_firefoxDragPosition", { x: 0, y: 0 });
|
|
139
|
-
c(this, "_instance", null);
|
|
140
|
-
c(this, "options", {});
|
|
141
|
-
c(this, "_firefoxFallback", (t) => {
|
|
142
|
-
if (!this._currentDrag.event)
|
|
143
|
-
return;
|
|
144
|
-
const e = t || window.event;
|
|
145
|
-
this._firefoxDragPosition.x = e.pageX || 0, this._firefoxDragPosition.y = e.pageY || 0;
|
|
146
|
-
});
|
|
147
|
-
this._iframe = t, this._injectStyles(), this._initializeDragGhost(), this._firefoxFallback = this._firefoxFallback.bind(this), document.addEventListener("dragover", this._firefoxFallback);
|
|
148
|
-
}
|
|
149
|
-
_injectStyles() {
|
|
150
|
-
if (!!!document.getElementById(O)) {
|
|
151
|
-
const e = document.createElement("style");
|
|
152
|
-
e.type = "text/css", e.id = O, e.innerHTML = `
|
|
153
|
-
.${x.DISPLAY_NONE}{display:none}
|
|
154
|
-
.${g}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}
|
|
155
|
-
.${m}{position:absolute;top:0;left:0;width:1px;height:1px;z-index:999;pointer-events:none;background-color:transparent;}
|
|
156
|
-
@keyframes ${T} {from{opacity: 0;}to {opacity: ${Y};}}
|
|
157
|
-
@keyframes ${b} {from{opacity: ${Y};}to {opacity: 0;}}
|
|
158
|
-
`, document.head.appendChild(e);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
_initializeDragGhost() {
|
|
162
|
-
const t = this._iframe.parentNode;
|
|
163
|
-
let e = t.querySelector(
|
|
164
|
-
"." + m
|
|
165
|
-
);
|
|
166
|
-
e || (e = document.createElement("div"), e.classList.add(m), e.innerText = " ", t.appendChild(e));
|
|
167
|
-
}
|
|
168
|
-
setInstance(t) {
|
|
169
|
-
this._instance = t;
|
|
170
|
-
}
|
|
171
|
-
dragStart(t, e, i = "rml_id") {
|
|
172
|
-
const s = this._iframe.parentNode;
|
|
173
|
-
if (p(s).position !== "relative") {
|
|
174
|
-
console.warn(
|
|
175
|
-
"Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly"
|
|
176
|
-
);
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
this._iframe.style.pointerEvents = "none";
|
|
180
|
-
let o = s.querySelector(
|
|
181
|
-
"." + g
|
|
182
|
-
);
|
|
183
|
-
o || (o = document.createElement("div"), o.classList.add(g), s.appendChild(o)), o.classList.remove(x.DISPLAY_NONE), e.target.getAttribute("draggable") || console.warn(
|
|
184
|
-
`Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`
|
|
185
|
-
);
|
|
186
|
-
const _ = s.querySelector(
|
|
187
|
-
"." + m
|
|
188
|
-
);
|
|
189
|
-
this._currentDrag.event = e;
|
|
190
|
-
const a = e.target.cloneNode();
|
|
191
|
-
a.style.position = "fixed", a.style.pointerEvents = "none", a.style.opacity = "0", a.style.animation = `${T} ${S} ${I}`, a.id = F, a.style.zIndex = "9999", document.body.appendChild(a), this._currentDrag.element = a;
|
|
192
|
-
const h = e.target.getBoundingClientRect();
|
|
193
|
-
this._currentDrag.offset || (this._currentDrag.offset = { x: 0, y: 0 });
|
|
194
|
-
const { clientX: u, clientY: f } = w(
|
|
195
|
-
e,
|
|
196
|
-
this._firefoxDragPosition
|
|
197
|
-
);
|
|
198
|
-
this._currentDrag.offset.x = u - h.left, this._currentDrag.offset.y = f - h.top, a.style.top = f + "px", a.style.left = u + "px", e instanceof DragEvent && e.dataTransfer && e.dataTransfer.setDragImage && e.dataTransfer.setDragImage(_, 0, 0);
|
|
199
|
-
const { x: d, y } = A(
|
|
200
|
-
s,
|
|
201
|
-
this._currentDrag.event || e,
|
|
202
|
-
this._firefoxDragPosition
|
|
203
|
-
), R = Math.max(1, d), X = Math.max(1, y);
|
|
204
|
-
E(this._instance) && this._instance.dragInObject(t, R, X, i);
|
|
205
|
-
}
|
|
206
|
-
dragUpdate(t) {
|
|
207
|
-
var l, _;
|
|
208
|
-
const e = this._iframe.parentNode, { x: i, y: s } = A(e, t, this._firefoxDragPosition);
|
|
209
|
-
if (i === 0 && s === 0)
|
|
210
|
-
return;
|
|
211
|
-
const r = Math.max(1, i), o = Math.max(1, s);
|
|
212
|
-
if (this._currentDrag.element) {
|
|
213
|
-
const { clientX: a, clientY: h } = w(
|
|
214
|
-
t,
|
|
215
|
-
this._firefoxDragPosition
|
|
216
|
-
), u = ((l = this._currentDrag.offset) == null ? void 0 : l.x) || 0, f = ((_ = this._currentDrag.offset) == null ? void 0 : _.y) || 0;
|
|
217
|
-
this._currentDrag.element.style.left = `${a - u}px`, this._currentDrag.element.style.top = `${h - f}px`;
|
|
218
|
-
const d = (this.options.dragInOverlapX || 0) + 1, y = (this.options.dragInOverlapY || 0) + 1;
|
|
219
|
-
r > d && o > y ? this._currentDrag.element.style.animation = `${b} ${S} ${I}` : this._currentDrag.element.style.animation = `${T} ${S} ${I}`;
|
|
220
|
-
}
|
|
221
|
-
if (!(r === 1 && o === 1) && E(this._instance)) {
|
|
222
|
-
let a = r, h = o;
|
|
223
|
-
if (M(t)) {
|
|
224
|
-
const u = this.options.fingerSize || 0;
|
|
225
|
-
a = Math.max(2, r + u), h = Math.max(2, o - u);
|
|
226
|
-
}
|
|
227
|
-
this._instance.updateDrag(a, h);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
dragEnd() {
|
|
231
|
-
this._iframe.style.pointerEvents = "all";
|
|
232
|
-
const t = this._iframe.parentNode;
|
|
233
|
-
E(this._instance) && this._instance.dragInObjectEnd(), this._currentDrag.element && document.body.removeChild(this._currentDrag.element), this._currentDrag = {}, this._firefoxDragPosition = { x: 0, y: 0 };
|
|
234
|
-
const e = t.querySelector(
|
|
235
|
-
"." + g
|
|
236
|
-
);
|
|
237
|
-
e && e.classList.add(x.DISPLAY_NONE);
|
|
238
|
-
}
|
|
239
|
-
touchStart(t, e, i = "rml_id") {
|
|
240
|
-
var o, l;
|
|
241
|
-
e.preventDefault();
|
|
242
|
-
const s = (_, a) => {
|
|
243
|
-
this.dragStart(t, a, i);
|
|
244
|
-
}, r = {};
|
|
245
|
-
typeof ((o = this.options) == null ? void 0 : o.touchDragDelay) == "number" && (r.delay = this.options.touchDragDelay), (l = this.options) != null && l.touchDragEpsilon && (r.epsilon = this.options.touchDragEpsilon), this._currentTouch = new z(
|
|
246
|
-
void 0,
|
|
247
|
-
{
|
|
248
|
-
onTouchDragStart: s
|
|
249
|
-
},
|
|
250
|
-
r
|
|
251
|
-
), this._currentTouch.onTouchStart(e);
|
|
252
|
-
}
|
|
253
|
-
touchMove(t) {
|
|
254
|
-
this._currentTouch && this._currentTouch.onTouchMove(t), this._currentDrag.event && this.dragUpdate(t);
|
|
255
|
-
}
|
|
256
|
-
touchEnd() {
|
|
257
|
-
this._currentTouch && this._currentTouch.onTouchEnd(), this._currentTouch = null, this.dragEnd();
|
|
258
|
-
}
|
|
259
|
-
dispose() {
|
|
260
|
-
document.removeEventListener("dragover", this._firefoxFallback);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
export {
|
|
264
|
-
U as DragIn
|
|
265
|
-
};
|