@tmagic/stage 1.0.0-rc.7 → 1.0.0-rc.8

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.
@@ -48,7 +48,7 @@ export default class StageDragResize extends EventEmitter {
48
48
  /** 目标节点 */
49
49
  public target?: HTMLElement;
50
50
  /** 目标节点在蒙层中的占位节点 */
51
- public dragEl: HTMLElement;
51
+ public dragEl: HTMLDivElement;
52
52
  /** Moveable拖拽类实例 */
53
53
  public moveable?: Moveable;
54
54
  /** 水平参考线 */
@@ -87,10 +87,9 @@ export default class StageDragResize extends EventEmitter {
87
87
  const oldTarget = this.target;
88
88
  this.target = el;
89
89
 
90
- this.init(el);
91
-
92
90
  // 从不能拖动到能拖动的节点之间切换,要重新创建moveable,不然dragStart不生效
93
91
  if (!this.moveable || this.target !== oldTarget) {
92
+ this.init(el);
94
93
  this.moveableHelper = MoveableHelper.create({
95
94
  useBeforeRender: true,
96
95
  useRender: false,
@@ -430,6 +429,10 @@ export default class StageDragResize extends EventEmitter {
430
429
  `;
431
430
 
432
431
  this.dragEl.id = `${DRAG_EL_ID_PREFIX}${el.id}`;
432
+
433
+ if (typeof this.core.config.updateDragEl === 'function') {
434
+ this.core.config.updateDragEl(this.dragEl, el);
435
+ }
433
436
  }
434
437
 
435
438
  private destroyDragEl(): void {
@@ -41,6 +41,7 @@ export default class StageHighlight extends EventEmitter {
41
41
  parent: this.core.mask.content,
42
42
  mask: this.core.mask,
43
43
  dr: this.core.dr,
44
+ core: this.core,
44
45
  });
45
46
  }
46
47
 
@@ -20,6 +20,7 @@
20
20
  import { EventEmitter } from 'events';
21
21
 
22
22
  import { Mode } from './const';
23
+ import StageCore from './StageCore';
23
24
  import StageDragResize from './StageDragResize';
24
25
  import StageMask from './StageMask';
25
26
  import type { Offset, TargetCalibrateConfig } from './types';
@@ -32,7 +33,8 @@ export default class TargetCalibrate extends EventEmitter {
32
33
  public parent: HTMLElement;
33
34
  public mask: StageMask;
34
35
  public dr: StageDragResize;
35
- public operationEl: HTMLElement;
36
+ public core: StageCore;
37
+ public operationEl: HTMLDivElement;
36
38
 
37
39
  constructor(config: TargetCalibrateConfig) {
38
40
  super();
@@ -40,6 +42,7 @@ export default class TargetCalibrate extends EventEmitter {
40
42
  this.parent = config.parent;
41
43
  this.mask = config.mask;
42
44
  this.dr = config.dr;
45
+ this.core = config.core;
43
46
 
44
47
  this.operationEl = globalThis.document.createElement('div');
45
48
  this.parent.append(this.operationEl);
@@ -58,6 +61,11 @@ export default class TargetCalibrate extends EventEmitter {
58
61
  `;
59
62
 
60
63
  this.operationEl.id = `${prefix}${el.id}`;
64
+
65
+ if (typeof this.core.config.updateDragEl === 'function') {
66
+ this.core.config.updateDragEl(this.operationEl, el);
67
+ }
68
+
61
69
  return this.operationEl;
62
70
  }
63
71
 
package/src/types.ts CHANGED
@@ -39,6 +39,7 @@ export type StageCoreConfig = {
39
39
  runtimeUrl?: string;
40
40
  render?: (renderer: StageCore) => Promise<HTMLElement> | HTMLElement;
41
41
  autoScrollIntoView?: boolean;
42
+ updateDragEl?: (el: HTMLDivElement, target: HTMLElement) => void;
42
43
  };
43
44
 
44
45
  export interface StageRenderConfig {
@@ -133,4 +134,5 @@ export interface TargetCalibrateConfig {
133
134
  parent: HTMLElement;
134
135
  mask: StageMask;
135
136
  dr: StageDragResize;
137
+ core: StageCore;
136
138
  }