@tmagic/stage 1.0.0-rc.4 → 1.0.0-rc.5
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0-rc.
|
|
2
|
+
"version": "1.0.0-rc.5",
|
|
3
3
|
"name": "@tmagic/stage",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"dist/*"
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@scena/guides": "^0.17.0",
|
|
30
|
-
"@tmagic/core": "^1.0.0-rc.
|
|
31
|
-
"@tmagic/schema": "^1.0.0-rc.
|
|
32
|
-
"@tmagic/utils": "^1.0.0-rc.
|
|
30
|
+
"@tmagic/core": "^1.0.0-rc.5",
|
|
31
|
+
"@tmagic/schema": "^1.0.0-rc.5",
|
|
32
|
+
"@tmagic/utils": "^1.0.0-rc.5",
|
|
33
33
|
"events": "^3.3.0",
|
|
34
34
|
"lodash-es": "^4.17.21",
|
|
35
35
|
"moveable": "^0.29.4",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"vite": "^2.3.7",
|
|
45
45
|
"vite-plugin-dts": "^0.9.6"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "d147b361d7e6123cda99c6ba68a2ac7e074be37f"
|
|
48
48
|
}
|
package/src/StageDragResize.ts
CHANGED
|
@@ -23,7 +23,7 @@ import type { MoveableOptions } from 'moveable';
|
|
|
23
23
|
import Moveable from 'moveable';
|
|
24
24
|
import MoveableHelper from 'moveable-helper';
|
|
25
25
|
|
|
26
|
-
import { DRAG_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, GuidesType, Mode } from './const';
|
|
26
|
+
import { DRAG_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, GuidesType, Mode, ZIndex } from './const';
|
|
27
27
|
import StageCore from './StageCore';
|
|
28
28
|
import type { Offset, SortEventData, StageDragResizeConfig } from './types';
|
|
29
29
|
import { getAbsolutePosition, getGuideLineFromCache, getMode, getOffset } from './util';
|
|
@@ -166,16 +166,12 @@ export default class StageDragResize extends EventEmitter {
|
|
|
166
166
|
|
|
167
167
|
this.updateDragEl(el);
|
|
168
168
|
|
|
169
|
-
this.setElementGuidelines(el);
|
|
170
|
-
|
|
171
169
|
this.moveableOptions = this.getOptions({
|
|
172
170
|
target: this.dragEl,
|
|
173
171
|
});
|
|
174
172
|
}
|
|
175
173
|
|
|
176
|
-
private setElementGuidelines(
|
|
177
|
-
const nodes = el.parentElement?.children || [];
|
|
178
|
-
|
|
174
|
+
private setElementGuidelines(nodes: HTMLElement[]) {
|
|
179
175
|
this.elementGuidelines.forEach((node) => {
|
|
180
176
|
node.remove();
|
|
181
177
|
});
|
|
@@ -186,7 +182,7 @@ export default class StageDragResize extends EventEmitter {
|
|
|
186
182
|
|
|
187
183
|
for (const node of nodes) {
|
|
188
184
|
const { width, height } = node.getBoundingClientRect();
|
|
189
|
-
if (node ===
|
|
185
|
+
if (node === this.target) continue;
|
|
190
186
|
const { left, top } = getOffset(node as HTMLElement);
|
|
191
187
|
const elementGuideline = document.createElement('div');
|
|
192
188
|
elementGuideline.style.cssText = `position: absolute;width: ${width}px;height: ${height}px;top: ${top}px;left: ${left}px`;
|
|
@@ -358,7 +354,7 @@ export default class StageDragResize extends EventEmitter {
|
|
|
358
354
|
const ghostEl = el.cloneNode(true) as HTMLElement;
|
|
359
355
|
const { top, left } = getAbsolutePosition(el, getOffset(el));
|
|
360
356
|
ghostEl.id = `${GHOST_EL_ID_PREFIX}${el.id}`;
|
|
361
|
-
ghostEl.style.zIndex =
|
|
357
|
+
ghostEl.style.zIndex = ZIndex.GHOST_EL;
|
|
362
358
|
ghostEl.style.opacity = '.5';
|
|
363
359
|
ghostEl.style.position = 'absolute';
|
|
364
360
|
ghostEl.style.left = `${left}px`;
|
|
@@ -382,7 +378,7 @@ export default class StageDragResize extends EventEmitter {
|
|
|
382
378
|
top: ${offset.top}px;
|
|
383
379
|
width: ${width}px;
|
|
384
380
|
height: ${height}px;
|
|
385
|
-
z-index:
|
|
381
|
+
z-index: ${ZIndex.DRAG_EL};
|
|
386
382
|
`;
|
|
387
383
|
|
|
388
384
|
this.dragEl.id = `${DRAG_EL_ID_PREFIX}${el.id}`;
|
|
@@ -404,6 +400,14 @@ export default class StageDragResize extends EventEmitter {
|
|
|
404
400
|
moveableOptions = moveableOptions(this.core);
|
|
405
401
|
}
|
|
406
402
|
|
|
403
|
+
const elementGuidelines: any = moveableOptions.elementGuidelines || this.target.parentElement?.children || [];
|
|
404
|
+
|
|
405
|
+
this.setElementGuidelines(elementGuidelines);
|
|
406
|
+
|
|
407
|
+
if (moveableOptions.elementGuidelines) {
|
|
408
|
+
delete moveableOptions.elementGuidelines;
|
|
409
|
+
}
|
|
410
|
+
|
|
407
411
|
return {
|
|
408
412
|
origin: false,
|
|
409
413
|
rootContainer: this.core.container,
|