lido-player 0.0.2-beta-15 → 0.0.2-beta-15-dev
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/dist/cjs/{decode-xNTgi2vl.js → decode-Xh5IDmFh.js} +1 -1
- package/dist/cjs/{index-BFTVvr1n.js → index-B9AON0kM.js} +114 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/lido-avatar_22.cjs.entry.js +52 -29
- package/dist/cjs/lido-player.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/calculator/lido-calculator.css +12 -12
- package/dist/collection/components/canvas/lido-canvas.css +32 -32
- package/dist/collection/components/canvas/lido-canvas.js +1 -1
- package/dist/collection/components/cell/lido-cell.js +1 -1
- package/dist/collection/components/column/lido-col.js +1 -1
- package/dist/collection/components/container/lido-container.js +2 -2
- package/dist/collection/components/float/lido-float.js +1 -1
- package/dist/collection/components/position/lido-pos.js +1 -1
- package/dist/collection/components/row/lido-row.js +1 -1
- package/dist/collection/components/slideFill/lido-slide-fill.js +1 -1
- package/dist/collection/components/text/lido-text.js +25 -1
- package/dist/collection/components/wrap/lido-wrap.js +1 -1
- package/dist/collection/utils/utils.js +4 -0
- package/dist/collection/utils/utilsHandlers/moveHandler.js +111 -0
- package/dist/components/index.js +1 -1
- package/dist/components/lido-calculator.js +1 -1
- package/dist/components/lido-canvas.js +1 -1
- package/dist/components/lido-cell.js +1 -1
- package/dist/components/lido-col.js +1 -1
- package/dist/components/lido-container.js +1 -1
- package/dist/components/lido-float.js +1 -1
- package/dist/components/lido-home.js +1 -1
- package/dist/components/lido-image.js +1 -1
- package/dist/components/lido-keyboard.js +1 -1
- package/dist/components/lido-pos.js +1 -1
- package/dist/components/lido-root.js +1 -1
- package/dist/components/lido-row.js +1 -1
- package/dist/components/lido-slide-fill.js +1 -1
- package/dist/components/lido-text.js +1 -1
- package/dist/components/lido-wrap.js +1 -1
- package/dist/components/{p-kmKkLN_7.js → p-BE25wHoo.js} +1 -1
- package/dist/components/p-BfwUqpXc.js +1 -0
- package/dist/components/{p-CDhOF-lb.js → p-Bw-OC9iR.js} +1 -1
- package/dist/components/{p-DVn4BL1l.js → p-C2p0KZh4.js} +1 -1
- package/dist/components/p-C5jvgiPE.js +1 -0
- package/dist/components/{p-CFNRhdZZ.js → p-CPYnt0P-.js} +1 -1
- package/dist/components/{p-B8USa8EO.js → p-CS6iRQJh.js} +1 -1
- package/dist/components/{p-DflRPD3L.js → p-CyGxEcn7.js} +1 -1
- package/dist/components/{p-BP79Al--.js → p-D-IYWSAa.js} +1 -1
- package/dist/components/{p-CbZUFX8q.js → p-DGvzMlyn.js} +2 -2
- package/dist/components/p-DbR5sNOj.js +1 -0
- package/dist/components/{p-D2RiLzSu.js → p-Sl9R-E6h.js} +1 -1
- package/dist/components/p-Uluc7jQ7.js +1 -0
- package/dist/components/{p-CLX-8DBk.js → p-useuhkjH.js} +1 -1
- package/dist/esm/{decode-DyBLrL5N.js → decode-C-vVYHke.js} +1 -1
- package/dist/esm/{index-B7s7KKj1.js → index-BswlHnsY.js} +114 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/lido-avatar_22.entry.js +52 -29
- package/dist/esm/lido-player.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/lido-player/index.esm.js +1 -1
- package/dist/lido-player/lido-player.esm.js +1 -1
- package/dist/lido-player/{p-CofY42mG.js → p-0l6uR1lH.js} +1 -1
- package/dist/lido-player/{p-Detap4vV.js → p-CYMdg2_E.js} +1 -1
- package/dist/lido-player/{p-05fff653.entry.js → p-b2c60372.entry.js} +2 -2
- package/dist/types/components/text/lido-text.d.ts +4 -0
- package/dist/types/components.d.ts +11 -0
- package/dist/types/utils/utilsHandlers/moveHandler.d.ts +1 -0
- package/package.json +1 -1
- package/dist/components/p-BJ4H1UxZ.js +0 -1
- package/dist/components/p-BiNO9454.js +0 -1
- package/dist/components/p-DH6lvh19.js +0 -1
- package/dist/components/p-DbDgJi-A.js +0 -1
|
@@ -7,18 +7,18 @@
|
|
|
7
7
|
padding: 2%;
|
|
8
8
|
box-sizing: border-box;
|
|
9
9
|
}
|
|
10
|
-
.lido-calculator-btn-special{
|
|
11
|
-
--btn-bg-color: #014D4D !important;
|
|
12
|
-
background-color:#014D4D !important;
|
|
13
|
-
--btn-shadow-color: #0a2f2f !important;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.lido-calculator-btn-default {
|
|
17
|
-
--btn-bg-color: #029A9A !important;
|
|
18
|
-
background-color: #029A9A !important;
|
|
19
|
-
color: #000;
|
|
20
|
-
--btn-shadow-color: #0f4242 !important ;
|
|
21
|
-
}
|
|
10
|
+
.lido-calculator-btn-special{
|
|
11
|
+
--btn-bg-color: #014D4D !important;
|
|
12
|
+
background-color:#014D4D !important;
|
|
13
|
+
--btn-shadow-color: #0a2f2f !important;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.lido-calculator-btn-default {
|
|
17
|
+
--btn-bg-color: #029A9A !important;
|
|
18
|
+
background-color: #029A9A !important;
|
|
19
|
+
color: #000;
|
|
20
|
+
--btn-shadow-color: #0f4242 !important ;
|
|
21
|
+
}
|
|
22
22
|
|
|
23
23
|
#lido-calculator-penIcon {
|
|
24
24
|
--btn-bg-color: #FB7038 !important;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
box-sizing: border-box;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.lido-canvas {
|
|
6
|
-
background: transparent;
|
|
7
|
-
border: none;
|
|
8
|
-
border-radius: 0;
|
|
9
|
-
overflow: hidden;
|
|
10
|
-
box-sizing: border-box;
|
|
11
|
-
}
|
|
12
|
-
#lido-exit-button {
|
|
13
|
-
padding: 6px 14px;
|
|
14
|
-
border: none;
|
|
15
|
-
background:transparent;
|
|
1
|
+
:host {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.lido-canvas {
|
|
6
|
+
background: transparent;
|
|
7
|
+
border: none;
|
|
8
|
+
border-radius: 0;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
}
|
|
12
|
+
#lido-exit-button {
|
|
13
|
+
padding: 6px 14px;
|
|
14
|
+
border: none;
|
|
15
|
+
background:transparent;
|
|
16
16
|
color: #fff;
|
|
17
|
-
border-radius: 6px;
|
|
18
|
-
cursor: pointer;
|
|
19
|
-
font-size: 14px;
|
|
20
|
-
position: absolute;
|
|
21
|
-
top: 0;
|
|
22
|
-
right: 0;
|
|
23
|
-
z-index: 15;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
canvas {
|
|
27
|
-
/* flex: 1; */
|
|
28
|
-
touch-action: none;
|
|
29
|
-
display: block;
|
|
30
|
-
width: 100%;
|
|
31
|
-
height: 100%;
|
|
32
|
-
z-index: 10;
|
|
33
|
-
}
|
|
17
|
+
border-radius: 6px;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
font-size: 14px;
|
|
20
|
+
position: absolute;
|
|
21
|
+
top: 0;
|
|
22
|
+
right: 0;
|
|
23
|
+
z-index: 15;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
canvas {
|
|
27
|
+
/* flex: 1; */
|
|
28
|
+
touch-action: none;
|
|
29
|
+
display: block;
|
|
30
|
+
width: 100%;
|
|
31
|
+
height: 100%;
|
|
32
|
+
z-index: 10;
|
|
33
|
+
}
|
|
@@ -102,7 +102,7 @@ export class LidoCanvas {
|
|
|
102
102
|
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
103
103
|
}
|
|
104
104
|
render() {
|
|
105
|
-
return (h(Host, { key: '
|
|
105
|
+
return (h(Host, { key: '6bb47f06656ce667d23236e9f3c3a8f383885a43', id: "lido-canvas", class: "lido-canvas", style: this.style }, h("button", { key: 'fd0d1217bda63071fbf6496c2538c2a944b14181', id: "lido-exit-button", onClick: () => this.clearCanvas() }), h("canvas", { key: 'ed0333972bb7ce0fc4e14c81bb466ea895ce65e0', id: "lido-canvas" })));
|
|
106
106
|
}
|
|
107
107
|
static get is() { return "lido-canvas"; }
|
|
108
108
|
static get encapsulation() { return "shadow"; }
|
|
@@ -257,7 +257,7 @@ export class LidoCell {
|
|
|
257
257
|
this.el.className = `lido-${parseProp(this.layout, orientation)}`;
|
|
258
258
|
}
|
|
259
259
|
render() {
|
|
260
|
-
return (h(Host, { key: '
|
|
260
|
+
return (h(Host, { key: '73bdf9dd33fdd8322c35465de011697da112193a', id: this.id, class: "lido-cell", value: this.value, type: this.type, "tab-index": this.tabIndex, style: this.style, minDrops: this.minDrops, maxDrops: this.maxDrops, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, audio: this.audio, onTouch: this.onTouch, onCorrect: this.onCorrect, onInCorrect: this.onInCorrect, onEntry: this.onEntry, "flex-direction": this.flexDirection, "disable-speak": this.disableSpeak }, h("slot", { key: '6e9d4507b36716f04853d39ef66015441782aa88' })));
|
|
261
261
|
}
|
|
262
262
|
static get is() { return "lido-cell"; }
|
|
263
263
|
static get originalStyleUrls() {
|
|
@@ -78,7 +78,7 @@ export class LidoCol {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
render() {
|
|
81
|
-
return (h(Host, { key: '
|
|
81
|
+
return (h(Host, { key: '334206d6054442fec787cfb479a68ae164404730', id: this.id, class: "lido-col", type: this.type, "tab-index": this.tabIndex, value: this.value, style: this.style, minDrops: this.minDrops, maxDrops: this.maxDrops, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, audio: this.audio, onTouch: this.onTouch, onCorrect: this.onCorrect, onInCorrect: this.onInCorrect, onEntry: this.onEntry }, h("slot", { key: '590cd219bc5a02e6b96eafe108fb8b310daf941d' })));
|
|
82
82
|
}
|
|
83
83
|
static get is() { return "lido-col"; }
|
|
84
84
|
static get originalStyleUrls() {
|
|
@@ -171,7 +171,7 @@ export class LidoContainer {
|
|
|
171
171
|
this.handleWindowLoad = () => this.scaleContainer(this.el);
|
|
172
172
|
}
|
|
173
173
|
cleanupInteractionHandlers() {
|
|
174
|
-
this.el.querySelectorAll('[type="drag"], [type="slide"]').forEach(element => {
|
|
174
|
+
this.el.querySelectorAll('[type="drag"], [type="slide"], [move="true"]').forEach(element => {
|
|
175
175
|
element.dispatchEvent(new Event(LIDO_INTERACTION_CLEANUP_EVENT));
|
|
176
176
|
});
|
|
177
177
|
}
|
|
@@ -452,7 +452,7 @@ export class LidoContainer {
|
|
|
452
452
|
margin: this.margin,
|
|
453
453
|
userSelect: 'none', // Prevent any field selection
|
|
454
454
|
};
|
|
455
|
-
return (h(Host, { key: '
|
|
455
|
+
return (h(Host, { key: '1862e30fedda58726edc107f81fae1f63e96d009', id: "lido-container", Lang: this.Lang, "tab-index": 0, class: "lido-container", objective: this.objective, baseUrl: this.baseUrl, style: style, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, onTouch: this.onTouch, onInCorrect: this.onInCorrect, onCorrect: this.onCorrect, onEntry: this.onEntry, "show-check": `${this.showCheck}`, "is-continue-on-correct": `${this.isContinueOnCorrect}`, "is-allow-only-correct": `${this.isAllowOnlyCorrect}`, canplay: `${this.canplay}`, appendToDropOnCompletion: `${this.appendToDropOnCompletion}`, "show-prev-button": `${this.showPrevButton}`, "show-next-button": `${this.showNextButton}`, "show-drop-border": `${this.showDropBorder}`, "bg-image": this.bgImage, "exit-button-url": this.exitButtonUrl, "prev-button-url": this.prevButtonUrl, "next-button-url": this.nextButtonUrl, "speaker-button-url": this.speakerButtonUrl, "disable-speak": `${this.disableSpeak}`, "template-id": this.templateId, audio: this.audio, "highlight-word-by-word": `${this.highlightWordByWord}` }, h("lido-text", { key: '86fd014a61ba9cba6d67e2d921b2d8a8a289dbc7', visible: "false", id: this.templateId, audio: "", string: this.instructName }), h("slot", { key: 'c3128ea2164892757b32cb076d717436947f9a4c' })));
|
|
456
456
|
}
|
|
457
457
|
static get is() { return "lido-container"; }
|
|
458
458
|
static get originalStyleUrls() {
|
|
@@ -85,7 +85,7 @@ export class LidoFloat {
|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
render() {
|
|
88
|
-
return (h(Host, { key: '
|
|
88
|
+
return (h(Host, { key: 'c461f1142dd6addd9ceb41ade183b044b875681f', class: "lido-float", "float-direction": this.floatDirection, id: this.id, "tab-index": this.tabIndex, style: this.style, onEntry: this.onEntry }, h("slot", { key: '240439bfda6a9e4e2d67e6ae2b5c878d99e632b3' })));
|
|
89
89
|
}
|
|
90
90
|
static get is() { return "lido-float"; }
|
|
91
91
|
static get originalStyleUrls() {
|
|
@@ -131,7 +131,7 @@ export class LidoPos {
|
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
render() {
|
|
134
|
-
return (h(Host, { key: '
|
|
134
|
+
return (h(Host, { key: 'cfd38900b31991e89c21a099fc4f91f77663ae94', id: this.id, class: "lido-pos", type: this.type, "tab-index": this.tabIndex, style: this.style, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, minDrops: this.minDrops, maxDrops: this.maxDrops, value: this.value, audio: this.audio, onTouch: this.onTouch, onCorrect: this.onCorrect, onInCorrect: this.onInCorrect, onEntry: this.onEntry }, h("slot", { key: '73f7bfe2d8214693d6f40a4dab6d735906ad4eaa' })));
|
|
135
135
|
}
|
|
136
136
|
static get is() { return "lido-pos"; }
|
|
137
137
|
static get originalStyleUrls() {
|
|
@@ -77,7 +77,7 @@ export class LidoRow {
|
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
render() {
|
|
80
|
-
return (h(Host, { key: '
|
|
80
|
+
return (h(Host, { key: 'c69aea0b1b11d9aec167d1a4376f68073f91ca81', class: "lido-row", type: this.type, "tab-index": this.tabIndex, value: this.value, style: this.style, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, minDrops: this.minDrops, maxDrops: this.maxDrops, audio: this.audio, onTouch: this.onTouch, onCorrect: this.onCorrect, onInCorrect: this.onInCorrect, onEntry: this.onEntry, "disable-speak": this.disableSpeak }, h("slot", { key: '8756ee0447057cddb949e23decbde5fe4d1d25c8' })));
|
|
81
81
|
}
|
|
82
82
|
static get is() { return "lido-row"; }
|
|
83
83
|
static get originalStyleUrls() {
|
|
@@ -218,7 +218,7 @@ export class LidoSlideFill {
|
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
render() {
|
|
221
|
-
return (h(Host, { key: '
|
|
221
|
+
return (h(Host, { key: 'a19d35ba055a5ed9ab38adb02f37c9cb634c272d', id: this.id, class: "lido-slide-fill", src: this.src, fill: this.fill, fillDirection: this.fillDirection, slider: this.slider, style: this.style, min: this.min, max: this.max, division: this.division, numberType: this.numberType, onEntry: this.onEntry, type: this.type, "disable-speak": this.disableSpeak }, h("div", { key: '987f42b3c213f570714b2ddf600243e83c3b12ad', innerHTML: this.svgContent, class: "lido-svg-element" })));
|
|
222
222
|
}
|
|
223
223
|
static get is() { return "lido-slide-fill"; }
|
|
224
224
|
static get originalStyleUrls() {
|
|
@@ -59,6 +59,10 @@ export class LidoText {
|
|
|
59
59
|
* The ARIA hidden attribute of the container. Used for accessibility to hide the element.
|
|
60
60
|
*/
|
|
61
61
|
this.ariaHidden = '';
|
|
62
|
+
/**
|
|
63
|
+
* Allows the text element to be freely moved by pointer/touch and persists the final x/y attributes.
|
|
64
|
+
*/
|
|
65
|
+
this.move = 'false';
|
|
62
66
|
/**
|
|
63
67
|
* X-axis (horizontal) position of the text component (CSS value, e.g., '10px', '5vw').
|
|
64
68
|
*/
|
|
@@ -256,7 +260,7 @@ export class LidoText {
|
|
|
256
260
|
}
|
|
257
261
|
}
|
|
258
262
|
render() {
|
|
259
|
-
return (h(Host, { key: '
|
|
263
|
+
return (h(Host, { key: '30e77a008aba08f90f88541574f70588bb8a2cd6', class: "lido-text", value: this.value, type: this.type, "tab-index": this.tabIndex, audio: this.audio, onTouch: this.onTouch, onCorrect: this.onCorrect, onInCorrect: this.onInCorrect, onEntry: this.onEntry, minDrops: this.minDrops, maxDrops: this.maxDrops, id: this.id, style: this.style, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, move: this.move, "span-type": this.spanType, "disable-speak": `${this.disableSpeak}` }, this.spanType !== '' ? h("div", { class: "lido-text-content" }, " ", i18next.t(this.string)) : i18next.t(this.string)));
|
|
260
264
|
}
|
|
261
265
|
static get is() { return "lido-text"; }
|
|
262
266
|
static get originalStyleUrls() {
|
|
@@ -511,6 +515,26 @@ export class LidoText {
|
|
|
511
515
|
"attribute": "aria-hidden",
|
|
512
516
|
"defaultValue": "''"
|
|
513
517
|
},
|
|
518
|
+
"move": {
|
|
519
|
+
"type": "string",
|
|
520
|
+
"mutable": false,
|
|
521
|
+
"complexType": {
|
|
522
|
+
"original": "string",
|
|
523
|
+
"resolved": "string",
|
|
524
|
+
"references": {}
|
|
525
|
+
},
|
|
526
|
+
"required": false,
|
|
527
|
+
"optional": false,
|
|
528
|
+
"docs": {
|
|
529
|
+
"tags": [],
|
|
530
|
+
"text": "Allows the text element to be freely moved by pointer/touch and persists the final x/y attributes."
|
|
531
|
+
},
|
|
532
|
+
"getter": false,
|
|
533
|
+
"setter": false,
|
|
534
|
+
"reflect": false,
|
|
535
|
+
"attribute": "move",
|
|
536
|
+
"defaultValue": "'false'"
|
|
537
|
+
},
|
|
514
538
|
"x": {
|
|
515
539
|
"type": "string",
|
|
516
540
|
"mutable": false,
|
|
@@ -75,7 +75,7 @@ export class LidoWrap {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
render() {
|
|
78
|
-
return (h(Host, { key: '
|
|
78
|
+
return (h(Host, { key: '58b1e37a1787349d3ccd2bc6952d94a7d945e234', class: "lido-wrap", value: this.value, type: this.type, "tab-index": this.tabIndex, style: this.style, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, audio: this.audio, minDrops: this.minDrops, maxDrops: this.maxDrops, onTouch: this.onTouch, onCorrect: this.onCorrect, onInCorrect: this.onInCorrect, onEntry: this.onEntry, disableSpeak: this.disableSpeak }, h("slot", { key: '44389fcc3d2e86faf291b74bfe50b55d467a7278' })));
|
|
79
79
|
}
|
|
80
80
|
static get is() { return "lido-wrap"; }
|
|
81
81
|
static get originalStyleUrls() {
|
|
@@ -7,6 +7,7 @@ import { AudioPlayer } from "./audioPlayer";
|
|
|
7
7
|
import { enableReorderDrag } from "./utilsHandlers/sortHandler";
|
|
8
8
|
import { slideAnimation, slidingWithScaling } from "./utilsHandlers/slideHandler";
|
|
9
9
|
import { enableDraggingWithScaling, enableOptionArea, getElementScale, handleDropElement, appendingDragElementsInDrop, multiplyBeedsCalculation } from "./utilsHandlers/dragDropHandler";
|
|
10
|
+
import { enableFreeMove } from "./utilsHandlers/moveHandler";
|
|
10
11
|
import { addClickListenerForClickType, onTouchListenerForOnTouch } from "./utilsHandlers/clickHandler";
|
|
11
12
|
import { evaluate, isArray } from "mathjs";
|
|
12
13
|
import { fillSlideHandle } from "./utilsHandlers/floatHandler";
|
|
@@ -62,6 +63,9 @@ export const initEventsForElement = async (element, type) => {
|
|
|
62
63
|
}
|
|
63
64
|
const onEntry = element.getAttribute('onEntry');
|
|
64
65
|
await executeActions(onEntry, element);
|
|
66
|
+
if (element.getAttribute('move') === 'true') {
|
|
67
|
+
enableFreeMove(element);
|
|
68
|
+
}
|
|
65
69
|
switch (type) {
|
|
66
70
|
case 'drag': {
|
|
67
71
|
enableDraggingWithScaling(element);
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { LIDO_INTERACTION_CLEANUP_EVENT, LidoContainer } from "../constants";
|
|
2
|
+
const getContainerScale = (container) => {
|
|
3
|
+
const transform = window.getComputedStyle(container).transform;
|
|
4
|
+
if (!transform || transform === 'none')
|
|
5
|
+
return 1;
|
|
6
|
+
const matrix = new DOMMatrixReadOnly(transform);
|
|
7
|
+
return matrix.a || 1;
|
|
8
|
+
};
|
|
9
|
+
const readPixelPosition = (value, fallback) => {
|
|
10
|
+
const parsed = parseFloat(value);
|
|
11
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
12
|
+
};
|
|
13
|
+
const getParentContainer = (element) => {
|
|
14
|
+
var _a;
|
|
15
|
+
return (_a = element.closest('lido-container')) !== null && _a !== void 0 ? _a : document.getElementById(LidoContainer);
|
|
16
|
+
};
|
|
17
|
+
export function enableFreeMove(element) {
|
|
18
|
+
var _a;
|
|
19
|
+
const moveElement = element;
|
|
20
|
+
(_a = moveElement.__lidoMoveCleanup) === null || _a === void 0 ? void 0 : _a.call(moveElement);
|
|
21
|
+
const container = getParentContainer(element);
|
|
22
|
+
if (!container)
|
|
23
|
+
return;
|
|
24
|
+
let isMoving = false;
|
|
25
|
+
let didMove = false;
|
|
26
|
+
let startX = 0;
|
|
27
|
+
let startY = 0;
|
|
28
|
+
let initialLeft = 0;
|
|
29
|
+
let initialTop = 0;
|
|
30
|
+
const onStart = (event) => {
|
|
31
|
+
if (container.getAttribute('canplay') !== 'false')
|
|
32
|
+
return;
|
|
33
|
+
const point = event instanceof MouseEvent ? event : event.touches[0];
|
|
34
|
+
if (!point)
|
|
35
|
+
return;
|
|
36
|
+
const computedStyle = window.getComputedStyle(element);
|
|
37
|
+
if (computedStyle.position === 'static') {
|
|
38
|
+
element.style.position = 'absolute';
|
|
39
|
+
}
|
|
40
|
+
isMoving = true;
|
|
41
|
+
didMove = false;
|
|
42
|
+
startX = point.clientX;
|
|
43
|
+
startY = point.clientY;
|
|
44
|
+
initialLeft = readPixelPosition(element.style.left || computedStyle.left, element.offsetLeft);
|
|
45
|
+
initialTop = readPixelPosition(element.style.top || computedStyle.top, element.offsetTop);
|
|
46
|
+
element.style.cursor = 'grabbing';
|
|
47
|
+
element.style.transition = 'none';
|
|
48
|
+
element.style.zIndex = element.style.zIndex || element.getAttribute('z') || '1';
|
|
49
|
+
document.addEventListener('mousemove', onMove);
|
|
50
|
+
document.addEventListener('mouseup', onEnd);
|
|
51
|
+
document.addEventListener('touchmove', onMove, { passive: false });
|
|
52
|
+
document.addEventListener('touchend', onEnd);
|
|
53
|
+
};
|
|
54
|
+
const onMove = (event) => {
|
|
55
|
+
if (!isMoving)
|
|
56
|
+
return;
|
|
57
|
+
if (event.cancelable)
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
const point = event instanceof MouseEvent ? event : event.touches[0];
|
|
60
|
+
if (!point)
|
|
61
|
+
return;
|
|
62
|
+
didMove = true;
|
|
63
|
+
const scale = getContainerScale(container);
|
|
64
|
+
const nextLeft = initialLeft + (point.clientX - startX) / scale;
|
|
65
|
+
const nextTop = initialTop + (point.clientY - startY) / scale;
|
|
66
|
+
element.style.left = `${nextLeft}px`;
|
|
67
|
+
element.style.top = `${nextTop}px`;
|
|
68
|
+
};
|
|
69
|
+
const removeDocumentListeners = () => {
|
|
70
|
+
document.removeEventListener('mousemove', onMove);
|
|
71
|
+
document.removeEventListener('mouseup', onEnd);
|
|
72
|
+
document.removeEventListener('touchmove', onMove);
|
|
73
|
+
document.removeEventListener('touchend', onEnd);
|
|
74
|
+
};
|
|
75
|
+
const onEnd = () => {
|
|
76
|
+
if (!isMoving)
|
|
77
|
+
return;
|
|
78
|
+
isMoving = false;
|
|
79
|
+
removeDocumentListeners();
|
|
80
|
+
element.style.cursor = 'move';
|
|
81
|
+
if (!didMove)
|
|
82
|
+
return;
|
|
83
|
+
element.setAttribute('x', element.style.left);
|
|
84
|
+
element.setAttribute('y', element.style.top);
|
|
85
|
+
};
|
|
86
|
+
const preventMovedClick = (event) => {
|
|
87
|
+
if (!didMove)
|
|
88
|
+
return;
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
event.stopPropagation();
|
|
91
|
+
didMove = false;
|
|
92
|
+
};
|
|
93
|
+
const cleanup = () => {
|
|
94
|
+
isMoving = false;
|
|
95
|
+
removeDocumentListeners();
|
|
96
|
+
element.removeEventListener('mousedown', onStart);
|
|
97
|
+
element.removeEventListener('touchstart', onStart);
|
|
98
|
+
element.removeEventListener('click', preventMovedClick, true);
|
|
99
|
+
element.removeEventListener(LIDO_INTERACTION_CLEANUP_EVENT, cleanup);
|
|
100
|
+
if (moveElement.__lidoMoveCleanup === cleanup) {
|
|
101
|
+
delete moveElement.__lidoMoveCleanup;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
moveElement.__lidoMoveCleanup = cleanup;
|
|
105
|
+
element.style.cursor = 'move';
|
|
106
|
+
element.style.touchAction = 'none';
|
|
107
|
+
element.addEventListener('mousedown', onStart);
|
|
108
|
+
element.addEventListener('touchstart', onStart);
|
|
109
|
+
element.addEventListener('click', preventMovedClick, true);
|
|
110
|
+
element.addEventListener(LIDO_INTERACTION_CLEANUP_EVENT, cleanup);
|
|
111
|
+
}
|