@tmagic/stage 1.0.0-rc.7 → 1.0.0

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.
@@ -1,4 +1,4 @@
1
- import { GuidesType, Mode } from './const';
1
+ import { Mode } from './const';
2
2
  import type { Offset } from './types';
3
3
  export declare const getOffset: (el: HTMLElement) => Offset;
4
4
  export declare const getAbsolutePosition: (el: HTMLElement, { top, left }: Offset) => {
@@ -7,10 +7,10 @@ export declare const getAbsolutePosition: (el: HTMLElement, { top, left }: Offse
7
7
  };
8
8
  export declare const getHost: (targetUrl: string) => string | undefined;
9
9
  export declare const isSameDomain: (targetUrl?: string, source?: string) => boolean;
10
- export declare const isAbsolute: (el?: HTMLElement | undefined) => boolean;
11
- export declare const isRelative: (el?: HTMLElement | undefined) => boolean;
12
- export declare const isStatic: (el?: HTMLElement | undefined) => boolean;
13
- export declare const isFixed: (el?: HTMLElement | undefined) => boolean;
10
+ export declare const isAbsolute: (style: CSSStyleDeclaration) => boolean;
11
+ export declare const isRelative: (style: CSSStyleDeclaration) => boolean;
12
+ export declare const isStatic: (style: CSSStyleDeclaration) => boolean;
13
+ export declare const isFixed: (style: CSSStyleDeclaration) => boolean;
14
14
  export declare const isFixedParent: (el: HTMLElement) => boolean;
15
15
  export declare const getMode: (el: HTMLElement) => Mode;
16
16
  export declare const getScrollParent: (element: HTMLElement, includeHidden?: boolean) => HTMLElement | null;
@@ -20,4 +20,3 @@ export declare const createDiv: ({ className, cssText }: {
20
20
  }) => HTMLDivElement;
21
21
  export declare const removeSelectedClassName: (doc: Document) => void;
22
22
  export declare const addSelectedClassName: (el: Element, doc: Document) => void;
23
- export declare const getGuideLineFromCache: (type: GuidesType) => number[];
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0-rc.7",
2
+ "version": "1.0.0",
3
3
  "name": "@tmagic/stage",
4
4
  "sideEffects": [
5
5
  "dist/*"
@@ -27,12 +27,12 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@scena/guides": "^0.17.0",
30
- "@tmagic/core": "1.0.0-rc.7",
31
- "@tmagic/schema": "1.0.0-rc.7",
32
- "@tmagic/utils": "1.0.0-rc.7",
30
+ "@tmagic/core": "1.0.0",
31
+ "@tmagic/schema": "1.0.0",
32
+ "@tmagic/utils": "1.0.0",
33
33
  "events": "^3.3.0",
34
34
  "lodash-es": "^4.17.21",
35
- "moveable": "^0.29.4",
35
+ "moveable": "^0.30.0",
36
36
  "moveable-helper": "^0.4.0"
37
37
  },
38
38
  "devDependencies": {
package/src/Rule.ts CHANGED
@@ -2,14 +2,13 @@ import EventEmitter from 'events';
2
2
 
3
3
  import Guides, { GuidesEvents } from '@scena/guides';
4
4
 
5
- import { GuidesType, H_GUIDE_LINE_STORAGE_KEY, V_GUIDE_LINE_STORAGE_KEY } from './const';
6
- import { getGuideLineFromCache } from './util';
5
+ import { GuidesType } from './const';
7
6
 
8
7
  export default class Rule extends EventEmitter {
9
8
  public hGuides: Guides;
10
9
  public vGuides: Guides;
11
- public horizontalGuidelines: number[] = getGuideLineFromCache(GuidesType.HORIZONTAL);
12
- public verticalGuidelines: number[] = getGuideLineFromCache(GuidesType.VERTICAL);
10
+ public horizontalGuidelines: number[] = [];
11
+ public verticalGuidelines: number[] = [];
13
12
 
14
13
  private container: HTMLDivElement;
15
14
  private containerResizeObserver: ResizeObserver;
@@ -28,6 +27,7 @@ export default class Rule extends EventEmitter {
28
27
  this.vGuides.resize();
29
28
  this.hGuides.resize();
30
29
  });
30
+
31
31
  this.containerResizeObserver.observe(this.container);
32
32
  }
33
33
 
@@ -45,33 +45,34 @@ export default class Rule extends EventEmitter {
45
45
  });
46
46
  }
47
47
 
48
- /**
49
- * 清空所有参考线
50
- */
51
- public clearGuides() {
52
- this.horizontalGuidelines = [];
53
- this.verticalGuidelines = [];
48
+ public setGuides([hLines, vLines]: [number[], number[]]) {
49
+ this.horizontalGuidelines = hLines;
50
+ this.verticalGuidelines = vLines;
54
51
 
55
- this.vGuides.setState({
56
- defaultGuides: [],
52
+ this.hGuides.setState({
53
+ defaultGuides: hLines,
57
54
  });
58
55
 
59
- this.hGuides.setState({
60
- defaultGuides: [],
56
+ this.vGuides.setState({
57
+ defaultGuides: vLines,
61
58
  });
62
59
 
63
60
  this.emit('changeGuides', {
64
- type: GuidesType.VERTICAL,
65
- guides: [],
61
+ type: GuidesType.HORIZONTAL,
62
+ guides: hLines,
66
63
  });
67
64
 
68
65
  this.emit('changeGuides', {
69
- type: GuidesType.HORIZONTAL,
70
- guides: [],
66
+ type: GuidesType.VERTICAL,
67
+ guides: vLines,
71
68
  });
69
+ }
72
70
 
73
- globalThis.localStorage.setItem(V_GUIDE_LINE_STORAGE_KEY, '[]');
74
- globalThis.localStorage.setItem(H_GUIDE_LINE_STORAGE_KEY, '[]');
71
+ /**
72
+ * 清空所有参考线
73
+ */
74
+ public clearGuides() {
75
+ this.setGuides([[], []]);
75
76
  }
76
77
 
77
78
  /**
@@ -101,7 +102,7 @@ export default class Rule extends EventEmitter {
101
102
  }
102
103
  }
103
104
 
104
- scrollRule(scrollTop: number) {
105
+ public scrollRule(scrollTop: number) {
105
106
  this.hGuides.scrollGuides(scrollTop);
106
107
  this.hGuides.scroll(0);
107
108
 
@@ -142,8 +143,6 @@ export default class Rule extends EventEmitter {
142
143
  type: GuidesType.HORIZONTAL,
143
144
  guides: this.horizontalGuidelines,
144
145
  });
145
-
146
- globalThis.localStorage.setItem(H_GUIDE_LINE_STORAGE_KEY, JSON.stringify(e.guides));
147
146
  };
148
147
 
149
148
  private vGuidesChangeGuidesHandler = (e: GuidesEvents['changeGuides']) => {
@@ -152,7 +151,5 @@ export default class Rule extends EventEmitter {
152
151
  type: GuidesType.VERTICAL,
153
152
  guides: this.verticalGuidelines,
154
153
  });
155
-
156
- globalThis.localStorage.setItem(V_GUIDE_LINE_STORAGE_KEY, JSON.stringify(e.guides));
157
154
  };
158
155
  }
package/src/StageCore.ts CHANGED
@@ -230,11 +230,11 @@ export default class StageCore extends EventEmitter {
230
230
  * 挂载Dom节点
231
231
  * @param el 将stage挂载到该Dom节点上
232
232
  */
233
- public mount(el: HTMLDivElement): void {
233
+ public async mount(el: HTMLDivElement) {
234
234
  this.container = el;
235
235
  const { mask, renderer } = this;
236
236
 
237
- renderer.mount(el);
237
+ await renderer.mount(el);
238
238
  mask.mount(el);
239
239
 
240
240
  this.emit('mounted');
@@ -25,8 +25,8 @@ import MoveableHelper from 'moveable-helper';
25
25
 
26
26
  import { DRAG_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, GuidesType, Mode, ZIndex } from './const';
27
27
  import StageCore from './StageCore';
28
- import type { Offset, SortEventData, StageDragResizeConfig } from './types';
29
- import { getAbsolutePosition, getGuideLineFromCache, getMode, getOffset } from './util';
28
+ import type { SortEventData, StageDragResizeConfig } from './types';
29
+ import { getAbsolutePosition, getMode, getOffset } from './util';
30
30
 
31
31
  /** 拖动状态 */
32
32
  enum ActionStatus {
@@ -48,13 +48,13 @@ 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
  /** 水平参考线 */
55
- public horizontalGuidelines: number[] = getGuideLineFromCache(GuidesType.HORIZONTAL);
55
+ public horizontalGuidelines: number[] = [];
56
56
  /** 垂直参考线 */
57
- public verticalGuidelines: number[] = getGuideLineFromCache(GuidesType.VERTICAL);
57
+ public verticalGuidelines: number[] = [];
58
58
  /** 对齐元素集合 */
59
59
  public elementGuidelines: HTMLElement[] = [];
60
60
  /** 布局方式:流式布局、绝对定位、固定定位 */
@@ -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,
@@ -112,7 +111,7 @@ export default class StageDragResize extends EventEmitter {
112
111
  */
113
112
  public updateMoveable(el = this.target): void {
114
113
  if (!this.moveable) throw new Error('未初始化moveable');
115
- if (!el) throw new Error('为选中任何节点');
114
+ if (!el) throw new Error('未选中任何节点');
116
115
 
117
116
  this.target = el;
118
117
 
@@ -133,7 +132,9 @@ export default class StageDragResize extends EventEmitter {
133
132
  this.moveableOptions.verticalGuidelines = guidelines;
134
133
  }
135
134
 
136
- this.updateMoveable();
135
+ if (this.moveable) {
136
+ this.updateMoveable();
137
+ }
137
138
  }
138
139
 
139
140
  public clearGuides() {
@@ -208,7 +209,7 @@ export default class StageDragResize extends EventEmitter {
208
209
  }
209
210
 
210
211
  private bindResizeEvent(): void {
211
- if (!this.moveable) throw new Error('moveable 为初始化');
212
+ if (!this.moveable) throw new Error('moveable 未初始化');
212
213
 
213
214
  const frame = {
214
215
  left: 0,
@@ -234,10 +235,16 @@ export default class StageDragResize extends EventEmitter {
234
235
 
235
236
  this.moveableHelper?.onResize(e);
236
237
 
238
+ // 流式布局
239
+ if (this.mode === Mode.SORTABLE) {
240
+ this.target.style.top = '0px';
241
+ } else {
242
+ this.target.style.left = `${frame.left + beforeTranslate[0]}px`;
243
+ this.target.style.top = `${frame.top + beforeTranslate[1]}px`;
244
+ }
245
+
237
246
  this.target.style.width = `${width}px`;
238
247
  this.target.style.height = `${height}px`;
239
- this.target.style.left = `${frame.left + beforeTranslate[0]}px`;
240
- this.target.style.top = `${frame.top + beforeTranslate[1]}px`;
241
248
  })
242
249
  .on('resizeEnd', () => {
243
250
  this.dragStatus = ActionStatus.END;
@@ -246,9 +253,12 @@ export default class StageDragResize extends EventEmitter {
246
253
  }
247
254
 
248
255
  private bindDragEvent(): void {
249
- if (!this.moveable) throw new Error('moveable 为初始化');
256
+ if (!this.moveable) throw new Error('moveable 未初始化');
250
257
 
251
- let offset: Offset | null = null;
258
+ const frame = {
259
+ left: 0,
260
+ top: 0,
261
+ };
252
262
 
253
263
  this.moveable
254
264
  .on('dragStart', (e) => {
@@ -261,29 +271,25 @@ export default class StageDragResize extends EventEmitter {
261
271
  if (this.mode === Mode.SORTABLE) {
262
272
  this.ghostEl = this.generateGhostEl(this.target);
263
273
  }
274
+
275
+ frame.top = this.target.offsetTop;
276
+ frame.left = this.target.offsetLeft;
264
277
  })
265
278
  .on('drag', (e) => {
266
279
  if (!this.target || !this.dragEl) return;
267
280
 
268
- if (!offset) {
269
- offset = getAbsolutePosition(this.target, { left: 0, top: 0 });
270
- }
271
-
272
281
  this.dragStatus = ActionStatus.ING;
273
282
 
274
- const { left, top } = e;
275
-
276
283
  // 流式布局
277
284
  if (this.ghostEl) {
278
- this.dragEl.style.top = `${top}px`;
279
- this.ghostEl.style.top = `${top + offset.top}px`;
285
+ this.ghostEl.style.top = `${frame.top + e.beforeTranslate[1]}px`;
280
286
  return;
281
287
  }
282
288
 
283
289
  this.moveableHelper?.onDrag(e);
284
290
 
285
- this.target.style.left = `${left + offset.left}px`;
286
- this.target.style.top = `${top + offset.top}px`;
291
+ this.target.style.left = `${frame.left + e.beforeTranslate[0]}px`;
292
+ this.target.style.top = `${frame.top + e.beforeTranslate[1]}px`;
287
293
  })
288
294
  .on('dragEnd', () => {
289
295
  // 点击不拖动时会触发dragStart和dragEnd,但是不会有drag事件
@@ -296,7 +302,6 @@ export default class StageDragResize extends EventEmitter {
296
302
  this.update();
297
303
  }
298
304
  }
299
- offset = null;
300
305
 
301
306
  this.dragStatus = ActionStatus.END;
302
307
  this.destroyGhostEl();
@@ -304,7 +309,7 @@ export default class StageDragResize extends EventEmitter {
304
309
  }
305
310
 
306
311
  private bindRotateEvent(): void {
307
- if (!this.moveable) throw new Error('moveable 为初始化');
312
+ if (!this.moveable) throw new Error('moveable 未初始化');
308
313
 
309
314
  this.moveable
310
315
  .on('rotateStart', (e) => {
@@ -331,7 +336,7 @@ export default class StageDragResize extends EventEmitter {
331
336
  }
332
337
 
333
338
  private bindScaleEvent(): void {
334
- if (!this.moveable) throw new Error('moveable 为初始化');
339
+ if (!this.moveable) throw new Error('moveable 未初始化');
335
340
 
336
341
  this.moveable
337
342
  .on('scaleStart', (e) => {
@@ -430,6 +435,10 @@ export default class StageDragResize extends EventEmitter {
430
435
  `;
431
436
 
432
437
  this.dragEl.id = `${DRAG_EL_ID_PREFIX}${el.id}`;
438
+
439
+ if (typeof this.core.config.updateDragEl === 'function') {
440
+ this.core.config.updateDragEl(this.dragEl, el);
441
+ }
433
442
  }
434
443
 
435
444
  private destroyDragEl(): void {
@@ -492,7 +501,8 @@ export default class StageDragResize extends EventEmitter {
492
501
 
493
502
  bounds: {
494
503
  top: 0,
495
- left: 0,
504
+ // 设置0的话无法移动到left为0,所以只能设置为-1
505
+ left: -1,
496
506
  right: this.container.clientWidth,
497
507
  bottom: this.container.clientHeight,
498
508
  ...(moveableOptions.bounds || {}),
@@ -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
 
@@ -81,10 +81,6 @@ export default class StageRender extends EventEmitter {
81
81
  }
82
82
 
83
83
  el.appendChild<HTMLIFrameElement>(this.iframe);
84
-
85
- this.contentWindow = this.iframe?.contentWindow as RuntimeWindow;
86
-
87
- this.contentWindow.magic = this.getMagicApi();
88
84
  } else {
89
85
  throw Error('mount 失败');
90
86
  }
@@ -113,7 +109,9 @@ export default class StageRender extends EventEmitter {
113
109
  }
114
110
 
115
111
  private loadHandler = async () => {
116
- this.emit('onload');
112
+ this.contentWindow = this.iframe?.contentWindow as RuntimeWindow;
113
+
114
+ this.contentWindow.magic = this.getMagicApi();
117
115
 
118
116
  if (this.render) {
119
117
  const el = await this.render(this.core);
@@ -121,5 +119,14 @@ export default class StageRender extends EventEmitter {
121
119
  this.iframe?.contentDocument?.body?.appendChild(el);
122
120
  }
123
121
  }
122
+
123
+ this.emit('onload');
124
+
125
+ this.contentWindow.postMessage(
126
+ {
127
+ tmagicRuntimeReady: true,
128
+ },
129
+ '*',
130
+ );
124
131
  };
125
132
  }
@@ -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/const.ts CHANGED
@@ -22,7 +22,7 @@ export const GHOST_EL_ID_PREFIX = 'ghost_el_';
22
22
  /** 拖动的时候需要在蒙层中创建一个占位节点,该节点的id前缀 */
23
23
  export const DRAG_EL_ID_PREFIX = 'drag_el_';
24
24
 
25
- /** 高亮事需要在蒙层中创建一个占位节点,该节点的id前缀 */
25
+ /** 高亮时需要在蒙层中创建一个占位节点,该节点的id前缀 */
26
26
  export const HIGHLIGHT_EL_ID_PREFIX = 'highlight_el_';
27
27
 
28
28
  /** 默认放到缩小倍数 */
@@ -68,6 +68,3 @@ export enum Mode {
68
68
 
69
69
  /** 选中节点的class name */
70
70
  export const SELECTED_CLASS = 'tmagic-stage-selected-area';
71
-
72
- export const H_GUIDE_LINE_STORAGE_KEY = '$MagicStageHorizontalGuidelinesData';
73
- export const V_GUIDE_LINE_STORAGE_KEY = '$MagicStageVerticalGuidelinesData';
package/src/index.ts CHANGED
@@ -23,4 +23,5 @@ export { default as StageRender } from './StageRender';
23
23
  export { default as StageMask } from './StageMask';
24
24
  export { default as StageDragResize } from './StageDragResize';
25
25
  export * from './types';
26
+ export * from './const';
26
27
  export default StageCore;
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 {
@@ -104,7 +105,7 @@ export interface Runtime {
104
105
  getApp?: () => Core;
105
106
  beforeSelect?: (el: HTMLElement) => Promise<boolean> | boolean;
106
107
  getSnapElements?: (el?: HTMLElement) => HTMLElement[];
107
- updateRootConfig: (config: MApp) => void;
108
+ updateRootConfig?: (config: MApp) => void;
108
109
  updatePageId?: (id: Id) => void;
109
110
  select?: (id: Id) => Promise<HTMLElement> | HTMLElement;
110
111
  add?: (data: UpdateData) => void;
@@ -133,4 +134,5 @@ export interface TargetCalibrateConfig {
133
134
  parent: HTMLElement;
134
135
  mask: StageMask;
135
136
  dr: StageDragResize;
137
+ core: StageCore;
136
138
  }
package/src/util.ts CHANGED
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import { GuidesType, H_GUIDE_LINE_STORAGE_KEY, Mode, SELECTED_CLASS, V_GUIDE_LINE_STORAGE_KEY } from './const';
19
+ import { Mode, SELECTED_CLASS } from './const';
20
20
  import type { Offset } from './types';
21
21
 
22
22
  const getParents = (el: Element, relative: Element) => {
@@ -73,31 +73,19 @@ export const isSameDomain = (targetUrl = '', source = globalThis.location.host)
73
73
  return getHost(targetUrl) === source;
74
74
  };
75
75
 
76
- export const isAbsolute = (el?: HTMLElement): boolean => {
77
- if (!el) return false;
78
- return getComputedStyle(el).position === 'absolute';
79
- };
76
+ export const isAbsolute = (style: CSSStyleDeclaration): boolean => style.position === 'absolute';
80
77
 
81
- export const isRelative = (el?: HTMLElement): boolean => {
82
- if (!el) return false;
83
- return getComputedStyle(el).position === 'relative';
84
- };
78
+ export const isRelative = (style: CSSStyleDeclaration): boolean => style.position === 'relative';
85
79
 
86
- export const isStatic = (el?: HTMLElement): boolean => {
87
- if (!el) return false;
88
- return getComputedStyle(el).position === 'static';
89
- };
80
+ export const isStatic = (style: CSSStyleDeclaration): boolean => style.position === 'static';
90
81
 
91
- export const isFixed = (el?: HTMLElement): boolean => {
92
- if (!el) return false;
93
- return getComputedStyle(el).position === 'fixed';
94
- };
82
+ export const isFixed = (style: CSSStyleDeclaration): boolean => style.position === 'fixed';
95
83
 
96
84
  export const isFixedParent = (el: HTMLElement) => {
97
85
  let fixed = false;
98
86
  let dom = el;
99
87
  while (dom) {
100
- fixed = isFixed(dom);
88
+ fixed = isFixed(getComputedStyle(dom));
101
89
  if (fixed) {
102
90
  break;
103
91
  }
@@ -112,7 +100,8 @@ export const isFixedParent = (el: HTMLElement) => {
112
100
 
113
101
  export const getMode = (el: HTMLElement): Mode => {
114
102
  if (isFixedParent(el)) return Mode.FIXED;
115
- if (isStatic(el) || isRelative(el)) return Mode.SORTABLE;
103
+ const style = getComputedStyle(el);
104
+ if (isStatic(style) || isRelative(style)) return Mode.SORTABLE;
116
105
  return Mode.ABSOLUTE;
117
106
  };
118
107
 
@@ -120,13 +109,14 @@ export const getScrollParent = (element: HTMLElement, includeHidden = false): HT
120
109
  let style = getComputedStyle(element);
121
110
  const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/;
122
111
 
123
- if (isFixed(element)) return null;
112
+ if (isFixed(style)) return null;
113
+
124
114
  for (let parent = element; parent.parentElement; ) {
125
115
  parent = parent.parentElement;
126
116
  style = getComputedStyle(parent);
127
- if (isAbsolute(element) && isStatic(element)) {
128
- continue;
129
- }
117
+
118
+ if (isAbsolute(style) && isStatic(style)) continue;
119
+
130
120
  if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) return parent;
131
121
  }
132
122
 
@@ -159,23 +149,3 @@ export const addSelectedClassName = (el: Element, doc: Document) => {
159
149
  item.classList.add(`${SELECTED_CLASS}-parents`);
160
150
  });
161
151
  };
162
-
163
- export const getGuideLineFromCache = (type: GuidesType): number[] => {
164
- const key = {
165
- [GuidesType.HORIZONTAL]: H_GUIDE_LINE_STORAGE_KEY,
166
- [GuidesType.VERTICAL]: V_GUIDE_LINE_STORAGE_KEY,
167
- }[type];
168
-
169
- if (!key) return [];
170
-
171
- const guideLineCacheData = globalThis.localStorage.getItem(key);
172
- if (guideLineCacheData) {
173
- try {
174
- return JSON.parse(guideLineCacheData) || [];
175
- } catch (e) {
176
- console.error(e);
177
- }
178
- }
179
-
180
- return [];
181
- };