@inditextech/weave-sdk 3.2.5 → 3.3.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.
package/dist/types.js CHANGED
@@ -21982,7 +21982,7 @@ var WeaveRegisterManager = class {
21982
21982
 
21983
21983
  //#endregion
21984
21984
  //#region package.json
21985
- var version = "3.2.5";
21985
+ var version = "3.3.0";
21986
21986
 
21987
21987
  //#endregion
21988
21988
  //#region src/managers/setup.ts
@@ -24150,11 +24150,15 @@ var GreedySnapper = class {
24150
24150
  reset() {
24151
24151
  this.snappedAngle = null;
24152
24152
  }
24153
+ angleDiff(a, b) {
24154
+ const diff = Math.abs(a - b) % 360;
24155
+ return diff > 180 ? 360 - diff : diff;
24156
+ }
24153
24157
  apply(angleDeg) {
24154
24158
  const { snapAngles, activateThreshold, releaseThreshold } = this.config;
24155
24159
  const normalized = (angleDeg % 360 + 360) % 360;
24156
24160
  if (this.snappedAngle !== null) {
24157
- const diff = Math.abs(normalized - this.snappedAngle);
24161
+ const diff = this.angleDiff(normalized, this.snappedAngle);
24158
24162
  if (diff > releaseThreshold) {
24159
24163
  this.snappedAngle = null;
24160
24164
  return normalized;
@@ -27477,8 +27481,8 @@ const WEAVE_STROKE_SINGLE_NODE_DEFAULT_CONFIG = { snapAngles: {
27477
27481
  270,
27478
27482
  315
27479
27483
  ],
27480
- activateThreshold: 5,
27481
- releaseThreshold: 10
27484
+ activateThreshold: 3,
27485
+ releaseThreshold: 4
27482
27486
  } };
27483
27487
  const WEAVE_STROKE_SINGLE_NODE_TIP_TYPE = {
27484
27488
  NONE: "none",
@@ -27600,7 +27604,7 @@ var WeaveArrowLineTipManager = class extends WeaveBaseLineTipManager {
27600
27604
  const height = instance.getAttrs()[`tip${this.capitalizeFirst(point)}Height`] ?? Math.sqrt(3) / 2 * 3;
27601
27605
  const triangle = new Konva.Line({
27602
27606
  id: `${instance.getAttrs().id}-tip-${point}`,
27603
- name: "lineTip",
27607
+ name: "lineTip stroke-internal",
27604
27608
  nodeId: instance.getAttrs().id,
27605
27609
  closed: true,
27606
27610
  stroke,
@@ -27666,7 +27670,7 @@ var WeaveCircleLineTipManager = class extends WeaveBaseLineTipManager {
27666
27670
  const radius = instance.getAttrs()[`tip${this.capitalizeFirst(point)}Radius`] ?? 1.5;
27667
27671
  const circle = new Konva.Circle({
27668
27672
  id: `${instance.getAttrs().id}-tip-${point}`,
27669
- name: "lineTip",
27673
+ name: "lineTip stroke-internal",
27670
27674
  nodeId: instance.getAttrs().id,
27671
27675
  radius,
27672
27676
  stroke: "black",
@@ -27780,7 +27784,7 @@ var WeaveSquareLineTipManager = class extends WeaveBaseLineTipManager {
27780
27784
  const width = instance.getAttrs()[`tip${this.capitalizeFirst(point)}Width`] ?? 3;
27781
27785
  const square = new Konva.Rect({
27782
27786
  id: `${instance.getAttrs().id}-tip-${point}`,
27783
- name: "lineTip",
27787
+ name: "lineTip stroke-internal",
27784
27788
  nodeId: instance.getAttrs().id,
27785
27789
  width,
27786
27790
  height: width,
@@ -27829,13 +27833,26 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27829
27833
  this.config = mergeExceptArrays(WEAVE_STROKE_SINGLE_NODE_DEFAULT_CONFIG, params?.config ?? {});
27830
27834
  this.handleNodeChanges = null;
27831
27835
  this.handleZoomChanges = null;
27836
+ this.shiftPressed = false;
27832
27837
  this.snapper = new GreedySnapper({
27833
27838
  snapAngles: this.config.snapAngles.angles,
27834
27839
  activateThreshold: this.config.snapAngles.activateThreshold,
27835
27840
  releaseThreshold: this.config.snapAngles.releaseThreshold
27836
27841
  });
27842
+ this.eventsInitialized = false;
27843
+ }
27844
+ initEvents() {
27845
+ if (this.eventsInitialized) return;
27846
+ window.addEventListener("keydown", (e) => {
27847
+ if (e.key === "Shift") this.shiftPressed = true;
27848
+ });
27849
+ window.addEventListener("keyup", (e) => {
27850
+ if (e.key === "Shift") this.shiftPressed = false;
27851
+ });
27852
+ this.eventsInitialized = true;
27837
27853
  }
27838
27854
  onRender(props) {
27855
+ this.initEvents();
27839
27856
  const stroke = new Konva.Group({
27840
27857
  ...props,
27841
27858
  name: `node ${WEAVE_STROKE_SINGLE_NODE_TYPE}`,
@@ -27847,7 +27864,7 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27847
27864
  ...props,
27848
27865
  id: `${stroke.getAttrs().id}-line`,
27849
27866
  nodeId: stroke.getAttrs().id,
27850
- name: void 0,
27867
+ name: "stroke-internal",
27851
27868
  x: 0,
27852
27869
  y: 0,
27853
27870
  strokeScaleEnabled: true,
@@ -27869,6 +27886,7 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27869
27886
  shouldOverdrawWholeArea: points.length !== 4
27870
27887
  };
27871
27888
  };
27889
+ this.setupDefaultNodeEvents(stroke);
27872
27890
  let originalStartHandleVisibility = null;
27873
27891
  let originalEndHandleVisibility = null;
27874
27892
  stroke.on("dragstart", () => {
@@ -27883,7 +27901,6 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27883
27901
  originalStartHandleVisibility = null;
27884
27902
  originalEndHandleVisibility = null;
27885
27903
  });
27886
- this.setupDefaultNodeEvents(stroke);
27887
27904
  if (!this.handleZoomChanges) {
27888
27905
  this.handleZoomChanges = () => {
27889
27906
  if (this.startHandle) this.startHandle.scale({
@@ -27900,12 +27917,10 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27900
27917
  if (!this.handleNodeChanges) {
27901
27918
  this.handleNodeChanges = (nodes) => {
27902
27919
  this.teardownSelection();
27903
- if (nodes.length === 1 && nodes[0].instance.getAttrs().nodeType === WEAVE_STROKE_SINGLE_NODE_TYPE) {
27904
- const strokeSelected = this.instance.getStage().findOne(`#${nodes[0].instance.getAttrs().id}`);
27905
- if (!strokeSelected) return;
27920
+ if (nodes.length === 1 && nodes[0].node?.type === WEAVE_STROKE_SINGLE_NODE_TYPE) {
27906
27921
  this.setupHandles();
27907
- this.showHandles(strokeSelected);
27908
- this.setupSelection(strokeSelected, true);
27922
+ this.showHandles(nodes[0].instance);
27923
+ this.setupSelection(nodes[0].instance, true);
27909
27924
  } else {
27910
27925
  this.startHandle?.setAttr("strokeId", void 0);
27911
27926
  this.startHandle?.visible(false);
@@ -27948,175 +27963,92 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27948
27963
  return stroke;
27949
27964
  }
27950
27965
  setupHandles() {
27951
- if (!this.startHandle) {
27952
- const startHandle = new Konva.Circle({
27953
- id: "line-start-handle",
27954
- radius: 5,
27955
- fill: "#ffffff",
27956
- stroke: "#000000",
27957
- strokeWidth: 1,
27958
- edgeDistanceDisableOnDrag: true,
27959
- scaleX: 1 / this.instance.getStage().scaleX(),
27960
- scaleY: 1 / this.instance.getStage().scaleY(),
27961
- draggable: true
27962
- });
27963
- startHandle.on("pointerover", () => {
27964
- this.instance.getStage().container().style.cursor = "move";
27965
- });
27966
- startHandle.on("pointerout", () => {
27967
- this.instance.getStage().container().style.cursor = "default";
27968
- });
27969
- startHandle.on("dragstart", (e) => {
27970
- const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
27971
- if (tr) tr.hide();
27972
- const strokeId = e.target.getAttr("strokeId");
27973
- const stroke = this.instance.getStage().findOne(`#${strokeId}`);
27974
- if (!stroke) return;
27975
- const points = stroke.getAttrs().linePoints;
27976
- if (points.length === 4) stroke.setAttr("eventTarget", true);
27977
- this.instance.emitEvent("onDrag", e.target);
27978
- });
27979
- startHandle.on("dragmove", (e) => {
27980
- const draggedTarget = e.target;
27981
- const strokeId = draggedTarget.getAttr("strokeId");
27982
- const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
27983
- if (!draggedStroke) return;
27984
- const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
27985
- if (!internalLine) return;
27986
- const points = draggedStroke.getAttrs().linePoints;
27987
- if (points.length !== 4) return;
27988
- this.teardownSelection();
27989
- const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
27990
- draggedStroke.setAttrs({ linePoints: [
27991
- newLinePoint.x,
27992
- newLinePoint.y,
27993
- points[2],
27994
- points[3]
27995
- ] });
27996
- this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
27997
- const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
27998
- this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
27999
- const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
28000
- this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28001
- this.setupSelection(draggedStroke);
28002
- });
28003
- startHandle.on("dragend", (e) => {
28004
- const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
28005
- if (tr) tr.show();
28006
- const draggedTarget = e.target;
28007
- const strokeId = draggedTarget.getAttr("strokeId");
28008
- const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
28009
- if (!draggedStroke) return;
28010
- const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
28011
- if (!internalLine) return;
28012
- const points = draggedStroke.getAttrs().linePoints;
28013
- if (points.length !== 4) return;
28014
- this.teardownSelection();
28015
- const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
28016
- draggedStroke.setAttrs({ linePoints: [
28017
- newLinePoint.x,
28018
- newLinePoint.y,
28019
- points[2],
28020
- points[3]
28021
- ] });
28022
- this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28023
- const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
28024
- this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28025
- const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
28026
- this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28027
- this.setupSelection(draggedStroke);
28028
- this.instance.updateNode(this.serialize(draggedStroke));
28029
- this.instance.emitEvent("onDrag", null);
28030
- });
28031
- this.startHandle = startHandle;
27966
+ if (!this.startHandle) this.setupHandle("start");
27967
+ if (!this.endHandle) this.setupHandle("end");
27968
+ }
27969
+ setupHandle(side) {
27970
+ const handleDragStart = (e) => {
27971
+ const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
27972
+ if (tr) tr.hide();
27973
+ const strokeId = e.target.getAttr("strokeId");
27974
+ const stroke = this.instance.getStage().findOne(`#${strokeId}`);
27975
+ if (!stroke) return;
27976
+ const points = stroke.getAttrs().linePoints;
27977
+ if (points.length === 4) stroke.setAttr("eventTarget", true);
27978
+ this.instance.emitEvent("onDrag", e.target);
27979
+ };
27980
+ const handleDragPosition = (side$1) => (e) => {
27981
+ const draggedTarget = e.target;
27982
+ const strokeId = draggedTarget.getAttr("strokeId");
27983
+ const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
27984
+ if (!draggedStroke) return;
27985
+ const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
27986
+ if (!internalLine) return;
27987
+ const points = draggedStroke.getAttrs().linePoints;
27988
+ if (points.length !== 4) return;
27989
+ this.teardownSelection();
27990
+ const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
27991
+ const pos = this.getDragPoint(draggedStroke, newLinePoint, side$1);
27992
+ if (side$1 === "start") draggedStroke.setAttrs({ linePoints: [
27993
+ pos.x,
27994
+ pos.y,
27995
+ points[2],
27996
+ points[3]
27997
+ ] });
27998
+ else draggedStroke.setAttrs({ linePoints: [
27999
+ points[0],
28000
+ points[1],
28001
+ pos.x,
28002
+ pos.y
28003
+ ] });
28004
+ this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28005
+ this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28006
+ const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
28007
+ this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28008
+ const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
28009
+ this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28010
+ this.setupSelection(draggedStroke);
28011
+ };
28012
+ const handleDragMove = (side$1) => (e) => {
28013
+ handleDragPosition(side$1)(e);
28014
+ };
28015
+ const handleDragEnd = (side$1) => (e) => {
28016
+ handleDragPosition(side$1)(e);
28017
+ const draggedTarget = e.target;
28018
+ const strokeId = draggedTarget.getAttr("strokeId");
28019
+ const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
28020
+ if (!draggedStroke) return;
28021
+ this.instance.updateNode(this.serialize(draggedStroke));
28022
+ this.instance.emitEvent("onDrag", null);
28023
+ };
28024
+ const handle = new Konva.Circle({
28025
+ id: `line-${side}-handle`,
28026
+ radius: 5,
28027
+ fill: "#ffffff",
28028
+ stroke: "#000000",
28029
+ strokeWidth: 1,
28030
+ edgeDistanceDisableOnDrag: true,
28031
+ scaleX: 1 / this.instance.getStage().scaleX(),
28032
+ scaleY: 1 / this.instance.getStage().scaleY(),
28033
+ draggable: true
28034
+ });
28035
+ handle.on("pointerover", () => {
28036
+ this.instance.getStage().container().style.cursor = "move";
28037
+ });
28038
+ handle.on("pointerout", () => {
28039
+ this.instance.getStage().container().style.cursor = "default";
28040
+ });
28041
+ handle.on("dragstart", handleDragStart);
28042
+ handle.on("dragmove", handleDragMove(side));
28043
+ handle.on("dragend", handleDragEnd(side));
28044
+ if (side === "start") {
28045
+ this.startHandle = handle;
28032
28046
  this.startHandle.visible(false);
28033
- this.instance.getSelectionLayer()?.add(this.startHandle);
28034
- }
28035
- if (!this.endHandle) {
28036
- const endHandle = new Konva.Circle({
28037
- id: "line-end-handle",
28038
- radius: 5,
28039
- fill: "#ffffff",
28040
- stroke: "#000000",
28041
- strokeWidth: 1,
28042
- edgeDistanceDisableOnDrag: true,
28043
- scaleX: 1 / this.instance.getStage().scaleX(),
28044
- scaleY: 1 / this.instance.getStage().scaleY(),
28045
- draggable: true
28046
- });
28047
- endHandle.on("pointerover", () => {
28048
- this.instance.getStage().container().style.cursor = "move";
28049
- });
28050
- endHandle.on("pointerout", () => {
28051
- this.instance.getStage().container().style.cursor = "default";
28052
- });
28053
- endHandle.on("dragstart", (e) => {
28054
- const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
28055
- if (tr) tr.hide();
28056
- const strokeId = e.target.getAttr("strokeId");
28057
- const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
28058
- if (!draggedStroke) return;
28059
- const points = draggedStroke.getAttrs().linePoints;
28060
- if (points.length !== 4) return;
28061
- if (points.length === 4) draggedStroke.setAttr("eventTarget", true);
28062
- this.instance.emitEvent("onDrag", e.target);
28063
- });
28064
- endHandle.on("dragmove", (e) => {
28065
- const draggedTarget = e.target;
28066
- const strokeId = draggedTarget.getAttr("strokeId");
28067
- const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
28068
- if (!draggedStroke) return;
28069
- const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
28070
- if (!internalLine) return;
28071
- const points = draggedStroke.getAttrs().linePoints;
28072
- if (points.length !== 4) return;
28073
- this.teardownSelection();
28074
- const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
28075
- draggedStroke.setAttrs({ linePoints: [
28076
- points[0],
28077
- points[1],
28078
- newLinePoint.x,
28079
- newLinePoint.y
28080
- ] });
28081
- this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28082
- const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
28083
- this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28084
- const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
28085
- this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28086
- this.setupSelection(draggedStroke);
28087
- });
28088
- endHandle.on("dragend", (e) => {
28089
- const tr = this.instance.getPlugin("nodesSelection")?.getTransformer();
28090
- if (tr) tr.show();
28091
- const draggedTarget = e.target;
28092
- const strokeId = draggedTarget.getAttr("strokeId");
28093
- const draggedStroke = this.instance.getStage().findOne(`#${strokeId}`);
28094
- if (!draggedStroke) return;
28095
- const internalLine = draggedStroke.findOne(`#${draggedStroke.getAttrs().id}-line`);
28096
- if (!internalLine) return;
28097
- const points = draggedStroke.getAttrs().linePoints;
28098
- if (points.length !== 4) return;
28099
- this.teardownSelection();
28100
- const newLinePoint = this.getLinePointFromHandle(draggedStroke, e);
28101
- draggedStroke.setAttrs({ linePoints: [
28102
- points[0],
28103
- points[1],
28104
- newLinePoint.x,
28105
- newLinePoint.y
28106
- ] });
28107
- this.positionHandle(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28108
- const tipStartStyle = draggedStroke.getAttrs().tipStartStyle ?? "none";
28109
- this.tipManagers[tipStartStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.START);
28110
- const tipEndStyle = draggedStroke.getAttrs().tipEndStyle ?? "none";
28111
- this.tipManagers[tipEndStyle]?.update(draggedStroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28112
- this.setupSelection(draggedStroke);
28113
- this.instance.updateNode(this.serialize(draggedStroke));
28114
- this.instance.emitEvent("onDrag", null);
28115
- });
28116
- this.endHandle = endHandle;
28047
+ } else {
28048
+ this.endHandle = handle;
28117
28049
  this.endHandle.visible(false);
28118
- this.instance.getSelectionLayer()?.add(this.endHandle);
28119
28050
  }
28051
+ this.instance.getSelectionLayer()?.add(handle);
28120
28052
  }
28121
28053
  showHandles(stroke) {
28122
28054
  if (this.startHandle === null || this.endHandle === null) return;
@@ -28140,7 +28072,7 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
28140
28072
  this.tipManagers[tipEndStyle]?.render(stroke, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28141
28073
  const internalLine = stroke.findOne(`#${stroke.getAttrs().id}-line`);
28142
28074
  if (internalLine) internalLine.setAttrs({
28143
- name: void 0,
28075
+ name: "stroke-internal",
28144
28076
  dash: nextProps.dash,
28145
28077
  fill: nextProps.fill,
28146
28078
  stroke: nextProps.stroke,
@@ -28200,20 +28132,19 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
28200
28132
  if (markSelected) instance.setAttrs({ isSelected: true });
28201
28133
  const hoverClone = instance.findOne(".hoverClone");
28202
28134
  if (hoverClone) return;
28203
- const internalLine = instance.findOne(`#${instance.getAttrs().id}-line`);
28204
- if (!internalLine) return;
28205
- const internalLineHover = internalLine.clone();
28206
- internalLineHover.setAttrs({
28207
- name: "hoverClone",
28208
- stroke: "#1a1aff",
28209
- listening: false,
28210
- draggable: false,
28211
- strokeWidth: 1,
28212
- points: instance.getAttrs().linePoints,
28213
- strokeScaleEnabled: false
28214
- });
28215
- instance.add(internalLineHover);
28216
- internalLineHover.moveToTop();
28135
+ const internalNodes = instance.find(".stroke-internal");
28136
+ for (const node of internalNodes) {
28137
+ const internalNode = node.clone();
28138
+ internalNode.setAttrs({
28139
+ name: "hoverClone",
28140
+ fill: "#1a1aff",
28141
+ stroke: "#1a1aff",
28142
+ listening: false,
28143
+ draggable: false
28144
+ });
28145
+ instance.add(internalNode);
28146
+ internalNode.moveToTop();
28147
+ }
28217
28148
  }
28218
28149
  teardownSelection() {
28219
28150
  const stage = this.instance.getStage();
@@ -28231,6 +28162,37 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
28231
28162
  const tipEndStyle = instance.getAttrs().tipEndStyle ?? "none";
28232
28163
  this.tipManagers[tipEndStyle]?.update(instance, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE.END);
28233
28164
  }
28165
+ getDragPoint(draggedStroke, newLinePoint, dragFrom) {
28166
+ const pos = {
28167
+ x: 0,
28168
+ y: 0
28169
+ };
28170
+ const linePoints = draggedStroke.getAttrs().linePoints;
28171
+ const fixed = dragFrom === "start" ? {
28172
+ x: linePoints[2],
28173
+ y: linePoints[3]
28174
+ } : {
28175
+ x: linePoints[0],
28176
+ y: linePoints[1]
28177
+ };
28178
+ if (this.shiftPressed) {
28179
+ let dx = newLinePoint.x - fixed.x;
28180
+ let dy = newLinePoint.y - fixed.y;
28181
+ const angle = Math.atan2(dy, dx);
28182
+ const angleDeg = angle * 180 / Math.PI;
28183
+ const snapped = this.snapper.apply(angleDeg);
28184
+ const dist = Math.hypot(dx, dy);
28185
+ const rad = snapped * Math.PI / 180;
28186
+ dx = Math.cos(rad) * dist;
28187
+ dy = Math.sin(rad) * dist;
28188
+ pos.x = fixed.x + dx;
28189
+ pos.y = fixed.y + dy;
28190
+ } else {
28191
+ pos.x = newLinePoint.x;
28192
+ pos.y = newLinePoint.y;
28193
+ }
28194
+ return pos;
28195
+ }
28234
28196
  };
28235
28197
 
28236
28198
  //#endregion