@tmagic/stage 1.1.0-beta.3 → 1.1.0-beta.4
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/tmagic-stage.es.js +48 -48
- package/dist/tmagic-stage.es.js.map +1 -1
- package/dist/tmagic-stage.umd.js +49 -47
- package/dist/tmagic-stage.umd.js.map +1 -1
- package/dist/types/src/StageDragResize.d.ts +1 -15
- package/dist/types/src/util.d.ts +15 -1
- package/package.json +4 -4
- package/src/StageDragResize.ts +3 -73
- package/src/util.ts +72 -2
package/dist/tmagic-stage.es.js
CHANGED
|
@@ -156,6 +156,52 @@ const calcValueByFontsize = (doc, value) => {
|
|
|
156
156
|
}
|
|
157
157
|
return value;
|
|
158
158
|
};
|
|
159
|
+
const down = (deltaTop, target) => {
|
|
160
|
+
let swapIndex = 0;
|
|
161
|
+
let addUpH = target.clientHeight;
|
|
162
|
+
const brothers = Array.from(target.parentNode?.children || []).filter((node) => !node.id.startsWith(GHOST_EL_ID_PREFIX));
|
|
163
|
+
const index = brothers.indexOf(target);
|
|
164
|
+
const downEls = brothers.slice(index + 1);
|
|
165
|
+
for (let i = 0; i < downEls.length; i++) {
|
|
166
|
+
const ele = downEls[i];
|
|
167
|
+
if (ele.style?.position === "fixed") {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
addUpH += ele.clientHeight / 2;
|
|
171
|
+
if (deltaTop <= addUpH) {
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
addUpH += ele.clientHeight / 2;
|
|
175
|
+
swapIndex = i;
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
src: target.id,
|
|
179
|
+
dist: downEls.length && swapIndex > -1 ? downEls[swapIndex].id : target.id
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
const up = (deltaTop, target) => {
|
|
183
|
+
const brothers = Array.from(target.parentNode?.children || []).filter((node) => !node.id.startsWith(GHOST_EL_ID_PREFIX));
|
|
184
|
+
const index = brothers.indexOf(target);
|
|
185
|
+
const upEls = brothers.slice(0, index);
|
|
186
|
+
let addUpH = target.clientHeight;
|
|
187
|
+
let swapIndex = upEls.length - 1;
|
|
188
|
+
for (let i = upEls.length - 1; i >= 0; i--) {
|
|
189
|
+
const ele = upEls[i];
|
|
190
|
+
if (!ele)
|
|
191
|
+
continue;
|
|
192
|
+
if (ele.style.position === "fixed")
|
|
193
|
+
continue;
|
|
194
|
+
addUpH += ele.clientHeight / 2;
|
|
195
|
+
if (-deltaTop <= addUpH)
|
|
196
|
+
break;
|
|
197
|
+
addUpH += ele.clientHeight / 2;
|
|
198
|
+
swapIndex = i;
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
src: target.id,
|
|
202
|
+
dist: upEls.length && swapIndex > -1 ? upEls[swapIndex].id : target.id
|
|
203
|
+
};
|
|
204
|
+
};
|
|
159
205
|
|
|
160
206
|
class StageDragResize extends EventEmitter {
|
|
161
207
|
constructor(config) {
|
|
@@ -554,7 +600,7 @@ class StageDragResize extends EventEmitter {
|
|
|
554
600
|
bounds: {
|
|
555
601
|
top: 0,
|
|
556
602
|
left: -1,
|
|
557
|
-
right: this.container.clientWidth,
|
|
603
|
+
right: this.container.clientWidth - 1,
|
|
558
604
|
bottom: this.container.clientHeight,
|
|
559
605
|
...moveableOptions.bounds || {}
|
|
560
606
|
},
|
|
@@ -563,52 +609,6 @@ class StageDragResize extends EventEmitter {
|
|
|
563
609
|
};
|
|
564
610
|
}
|
|
565
611
|
}
|
|
566
|
-
const down = (deltaTop, target) => {
|
|
567
|
-
let swapIndex = 0;
|
|
568
|
-
let addUpH = target.clientHeight;
|
|
569
|
-
const brothers = Array.from(target.parentNode?.children || []).filter((node) => !node.id.startsWith(GHOST_EL_ID_PREFIX));
|
|
570
|
-
const index = brothers.indexOf(target);
|
|
571
|
-
const downEls = brothers.slice(index + 1);
|
|
572
|
-
for (let i = 0; i < downEls.length; i++) {
|
|
573
|
-
const ele = downEls[i];
|
|
574
|
-
if (ele.style?.position === "fixed") {
|
|
575
|
-
continue;
|
|
576
|
-
}
|
|
577
|
-
addUpH += ele.clientHeight / 2;
|
|
578
|
-
if (deltaTop <= addUpH) {
|
|
579
|
-
break;
|
|
580
|
-
}
|
|
581
|
-
addUpH += ele.clientHeight / 2;
|
|
582
|
-
swapIndex = i;
|
|
583
|
-
}
|
|
584
|
-
return {
|
|
585
|
-
src: target.id,
|
|
586
|
-
dist: downEls.length && swapIndex > -1 ? downEls[swapIndex].id : target.id
|
|
587
|
-
};
|
|
588
|
-
};
|
|
589
|
-
const up = (deltaTop, target) => {
|
|
590
|
-
const brothers = Array.from(target.parentNode?.children || []).filter((node) => !node.id.startsWith(GHOST_EL_ID_PREFIX));
|
|
591
|
-
const index = brothers.indexOf(target);
|
|
592
|
-
const upEls = brothers.slice(0, index);
|
|
593
|
-
let addUpH = target.clientHeight;
|
|
594
|
-
let swapIndex = upEls.length - 1;
|
|
595
|
-
for (let i = upEls.length - 1; i >= 0; i--) {
|
|
596
|
-
const ele = upEls[i];
|
|
597
|
-
if (!ele)
|
|
598
|
-
continue;
|
|
599
|
-
if (ele.style.position === "fixed")
|
|
600
|
-
continue;
|
|
601
|
-
addUpH += ele.clientHeight / 2;
|
|
602
|
-
if (-deltaTop <= addUpH)
|
|
603
|
-
break;
|
|
604
|
-
addUpH += ele.clientHeight / 2;
|
|
605
|
-
swapIndex = i;
|
|
606
|
-
}
|
|
607
|
-
return {
|
|
608
|
-
src: target.id,
|
|
609
|
-
dist: upEls.length && swapIndex > -1 ? upEls[swapIndex].id : target.id
|
|
610
|
-
};
|
|
611
|
-
};
|
|
612
612
|
|
|
613
613
|
class TargetCalibrate extends EventEmitter {
|
|
614
614
|
constructor(config) {
|
|
@@ -1476,5 +1476,5 @@ class StageCore extends EventEmitter {
|
|
|
1476
1476
|
}
|
|
1477
1477
|
}
|
|
1478
1478
|
|
|
1479
|
-
export { CONTAINER_HIGHLIGHT_CLASS, DEFAULT_ZOOM, DRAG_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, GuidesType, HIGHLIGHT_EL_ID_PREFIX, Mode, MouseButton, PAGE_CLASS, SELECTED_CLASS, StageDragResize, StageMask, StageRender, ZIndex, addSelectedClassName, calcValueByFontsize, StageCore as default, getAbsolutePosition, getMode, getOffset, getScrollParent, getTargetElStyle, isAbsolute, isFixed, isFixedParent, isRelative, isStatic, removeSelectedClassName };
|
|
1479
|
+
export { CONTAINER_HIGHLIGHT_CLASS, DEFAULT_ZOOM, DRAG_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, GuidesType, HIGHLIGHT_EL_ID_PREFIX, Mode, MouseButton, PAGE_CLASS, SELECTED_CLASS, StageDragResize, StageMask, StageRender, ZIndex, addSelectedClassName, calcValueByFontsize, StageCore as default, down, getAbsolutePosition, getMode, getOffset, getScrollParent, getTargetElStyle, isAbsolute, isFixed, isFixedParent, isRelative, isStatic, removeSelectedClassName, up };
|
|
1480
1480
|
//# sourceMappingURL=tmagic-stage.es.js.map
|