@flowgram.ai/renderer 0.4.13 → 0.4.15

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/esm/index.js CHANGED
@@ -10,12 +10,12 @@ var __decorateClass = (decorators, target, key, kind) => {
10
10
  };
11
11
 
12
12
  // src/entities/flow-drag-entity.tsx
13
+ import { Rectangle } from "@flowgram.ai/utils";
13
14
  import {
14
15
  FlowTransitionLabelEnum,
15
16
  LABEL_SIDE_TYPE
16
17
  } from "@flowgram.ai/document";
17
18
  import { ConfigEntity, PlaygroundConfigEntity } from "@flowgram.ai/core";
18
- import { Rectangle } from "@flowgram.ai/utils";
19
19
 
20
20
  // src/components/utils.tsx
21
21
  import {
@@ -394,23 +394,24 @@ var FlowDragEntity = class extends ConfigEntity {
394
394
  this.containerDom = containerDom;
395
395
  this.containerX = x;
396
396
  this.containerY = y;
397
- const mouseToBottom = playgroundConfig.height + playgroundConfig.clientY - e.clientY;
397
+ const clientRect = this.playgroundConfigEntity.playgroundDomNode.getBoundingClientRect();
398
+ const mouseToBottom = playgroundConfig.height + clientRect.y - e.clientY;
398
399
  if (mouseToBottom < SCROLL_BOUNDING) {
399
400
  this._startScrollY(currentScrollY, true);
400
401
  return 1 /* BOTTOM */;
401
402
  }
402
- const mouseToTop = e.clientY - playgroundConfig.clientY;
403
+ const mouseToTop = e.clientY - clientRect.y;
403
404
  if (mouseToTop < SCROLL_BOUNDING) {
404
405
  this._startScrollY(currentScrollY, false);
405
406
  return 0 /* TOP */;
406
407
  }
407
408
  this._stopScrollY();
408
- const mouseToRight = playgroundConfig.width + playgroundConfig.clientX - e.clientX;
409
+ const mouseToRight = playgroundConfig.width + clientRect.x - e.clientX;
409
410
  if (mouseToRight < SCROLL_BOUNDING) {
410
411
  this._startScrollX(currentScrollX, true);
411
412
  return 3 /* RIGHT */;
412
413
  }
413
- const mouseToLeft = e.clientX - playgroundConfig.clientX;
414
+ const mouseToLeft = e.clientX - clientRect.x;
414
415
  if (mouseToLeft < SCROLL_BOUNDING + EDITOR_LEFT_BAR_WIDTH) {
415
416
  this._startScrollX(currentScrollX, false);
416
417
  return 2 /* LEFT */;
@@ -2416,8 +2417,9 @@ var FlowDragLayer = class extends Layer7 {
2416
2417
  const scale = this.playgroundConfigEntity.finalScale;
2417
2418
  if (this.containerRef.current) {
2418
2419
  const dragNode = this.containerRef.current.children?.[0];
2419
- const dragBlockX = event.clientX - (this.pipelineNode.offsetLeft || 0) - this.playgroundConfigEntity.config.clientX - (dragNode.clientWidth - this.dragOffset.x) * scale;
2420
- const dragBlockY = event.clientY - (this.pipelineNode.offsetTop || 0) - this.playgroundConfigEntity.config.clientY - (dragNode.clientHeight - this.dragOffset.y) * scale;
2420
+ const clientBounds = this.playgroundConfigEntity.getClientBounds();
2421
+ const dragBlockX = event.clientX - (this.pipelineNode.offsetLeft || 0) - clientBounds.x - (dragNode.clientWidth - this.dragOffset.x) * scale;
2422
+ const dragBlockY = event.clientY - (this.pipelineNode.offsetTop || 0) - clientBounds.y - (dragNode.clientHeight - this.dragOffset.y) * scale;
2421
2423
  const isBranch = this.service.isDragBranch;
2422
2424
  const draggingRect = new Rectangle8(
2423
2425
  dragBlockX,
@@ -2900,6 +2902,7 @@ FlowSelectorBoundsLayer = __decorateClass([
2900
2902
  // src/layers/flow-context-menu-layer.tsx
2901
2903
  import React17 from "react";
2902
2904
  import { inject as inject11, injectable as injectable12 } from "inversify";
2905
+ import { domUtils as domUtils9 } from "@flowgram.ai/utils";
2903
2906
  import {
2904
2907
  CommandRegistry as CommandRegistry2,
2905
2908
  ContextMenuService as ContextMenuService2,
@@ -2911,7 +2914,6 @@ import {
2911
2914
  PlaygroundConfigEntity as PlaygroundConfigEntity5,
2912
2915
  SelectionService as SelectionService2
2913
2916
  } from "@flowgram.ai/core";
2914
- import { domUtils as domUtils9 } from "@flowgram.ai/utils";
2915
2917
  var FlowContextMenuLayer = class extends Layer10 {
2916
2918
  constructor() {
2917
2919
  super(...arguments);
@@ -2938,8 +2940,9 @@ var FlowContextMenuLayer = class extends Layer10 {
2938
2940
  e.stopPropagation();
2939
2941
  e.preventDefault();
2940
2942
  this.nodeRef.current?.setVisible(true);
2941
- const dragBlockX = e.clientX - (this.pipelineNode.offsetLeft || 0) - this.playgroundConfigEntity.config.clientX;
2942
- const dragBlockY = e.clientY - (this.pipelineNode.offsetTop || 0) - this.playgroundConfigEntity.config.clientY;
2943
+ const clientBounds = this.playgroundConfigEntity.getClientBounds();
2944
+ const dragBlockX = e.clientX - (this.pipelineNode.offsetLeft || 0) - clientBounds.x;
2945
+ const dragBlockY = e.clientY - (this.pipelineNode.offsetTop || 0) - clientBounds.y;
2943
2946
  this.node.style.left = `${dragBlockX}px`;
2944
2947
  this.node.style.top = `${dragBlockY}px`;
2945
2948
  },