@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.
@@ -162,6 +162,52 @@
162
162
  }
163
163
  return value;
164
164
  };
165
+ const down = (deltaTop, target) => {
166
+ let swapIndex = 0;
167
+ let addUpH = target.clientHeight;
168
+ const brothers = Array.from(target.parentNode?.children || []).filter((node) => !node.id.startsWith(GHOST_EL_ID_PREFIX));
169
+ const index = brothers.indexOf(target);
170
+ const downEls = brothers.slice(index + 1);
171
+ for (let i = 0; i < downEls.length; i++) {
172
+ const ele = downEls[i];
173
+ if (ele.style?.position === "fixed") {
174
+ continue;
175
+ }
176
+ addUpH += ele.clientHeight / 2;
177
+ if (deltaTop <= addUpH) {
178
+ break;
179
+ }
180
+ addUpH += ele.clientHeight / 2;
181
+ swapIndex = i;
182
+ }
183
+ return {
184
+ src: target.id,
185
+ dist: downEls.length && swapIndex > -1 ? downEls[swapIndex].id : target.id
186
+ };
187
+ };
188
+ const up = (deltaTop, target) => {
189
+ const brothers = Array.from(target.parentNode?.children || []).filter((node) => !node.id.startsWith(GHOST_EL_ID_PREFIX));
190
+ const index = brothers.indexOf(target);
191
+ const upEls = brothers.slice(0, index);
192
+ let addUpH = target.clientHeight;
193
+ let swapIndex = upEls.length - 1;
194
+ for (let i = upEls.length - 1; i >= 0; i--) {
195
+ const ele = upEls[i];
196
+ if (!ele)
197
+ continue;
198
+ if (ele.style.position === "fixed")
199
+ continue;
200
+ addUpH += ele.clientHeight / 2;
201
+ if (-deltaTop <= addUpH)
202
+ break;
203
+ addUpH += ele.clientHeight / 2;
204
+ swapIndex = i;
205
+ }
206
+ return {
207
+ src: target.id,
208
+ dist: upEls.length && swapIndex > -1 ? upEls[swapIndex].id : target.id
209
+ };
210
+ };
165
211
 
166
212
  class StageDragResize extends EventEmitter.EventEmitter {
167
213
  constructor(config) {
@@ -560,7 +606,7 @@
560
606
  bounds: {
561
607
  top: 0,
562
608
  left: -1,
563
- right: this.container.clientWidth,
609
+ right: this.container.clientWidth - 1,
564
610
  bottom: this.container.clientHeight,
565
611
  ...moveableOptions.bounds || {}
566
612
  },
@@ -569,52 +615,6 @@
569
615
  };
570
616
  }
571
617
  }
572
- const down = (deltaTop, target) => {
573
- let swapIndex = 0;
574
- let addUpH = target.clientHeight;
575
- const brothers = Array.from(target.parentNode?.children || []).filter((node) => !node.id.startsWith(GHOST_EL_ID_PREFIX));
576
- const index = brothers.indexOf(target);
577
- const downEls = brothers.slice(index + 1);
578
- for (let i = 0; i < downEls.length; i++) {
579
- const ele = downEls[i];
580
- if (ele.style?.position === "fixed") {
581
- continue;
582
- }
583
- addUpH += ele.clientHeight / 2;
584
- if (deltaTop <= addUpH) {
585
- break;
586
- }
587
- addUpH += ele.clientHeight / 2;
588
- swapIndex = i;
589
- }
590
- return {
591
- src: target.id,
592
- dist: downEls.length && swapIndex > -1 ? downEls[swapIndex].id : target.id
593
- };
594
- };
595
- const up = (deltaTop, target) => {
596
- const brothers = Array.from(target.parentNode?.children || []).filter((node) => !node.id.startsWith(GHOST_EL_ID_PREFIX));
597
- const index = brothers.indexOf(target);
598
- const upEls = brothers.slice(0, index);
599
- let addUpH = target.clientHeight;
600
- let swapIndex = upEls.length - 1;
601
- for (let i = upEls.length - 1; i >= 0; i--) {
602
- const ele = upEls[i];
603
- if (!ele)
604
- continue;
605
- if (ele.style.position === "fixed")
606
- continue;
607
- addUpH += ele.clientHeight / 2;
608
- if (-deltaTop <= addUpH)
609
- break;
610
- addUpH += ele.clientHeight / 2;
611
- swapIndex = i;
612
- }
613
- return {
614
- src: target.id,
615
- dist: upEls.length && swapIndex > -1 ? upEls[swapIndex].id : target.id
616
- };
617
- };
618
618
 
619
619
  class TargetCalibrate extends EventEmitter.EventEmitter {
620
620
  constructor(config) {
@@ -1499,6 +1499,7 @@
1499
1499
  exports.addSelectedClassName = addSelectedClassName;
1500
1500
  exports.calcValueByFontsize = calcValueByFontsize;
1501
1501
  exports["default"] = StageCore;
1502
+ exports.down = down;
1502
1503
  exports.getAbsolutePosition = getAbsolutePosition;
1503
1504
  exports.getMode = getMode;
1504
1505
  exports.getOffset = getOffset;
@@ -1510,6 +1511,7 @@
1510
1511
  exports.isRelative = isRelative;
1511
1512
  exports.isStatic = isStatic;
1512
1513
  exports.removeSelectedClassName = removeSelectedClassName;
1514
+ exports.up = up;
1513
1515
 
1514
1516
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
1515
1517