@particle-academy/fancy-flow 0.30.0 → 0.31.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/index.d.cts CHANGED
@@ -38,6 +38,18 @@ type FlowCanvasProps = Omit<ReactFlowProps<FlowNode, Edge>, "nodes" | "edges" |
38
38
  validateConnections?: boolean | ConnectionValidatorOptions;
39
39
  /** Show alignment guide lines while dragging, and snap to them. Default off. */
40
40
  showHelperLines?: boolean;
41
+ /**
42
+ * A bare mouse wheel over the canvas zooms it. Default **true**.
43
+ *
44
+ * Turn it off for a canvas embedded mid-page, where a reader scrolling past
45
+ * would otherwise get trapped zooming. With it off the wheel scrolls the page
46
+ * and **Shift+wheel** zooms instead.
47
+ *
48
+ * Either way, a wheel gesture that zooms never also scrolls the page — the
49
+ * two happening at once is the thing that makes an embedded canvas feel
50
+ * broken.
51
+ */
52
+ zoomOnWheel?: boolean;
41
53
  /** Optional toolbar / palette etc. rendered above the canvas. */
42
54
  toolbar?: ReactNode;
43
55
  className?: string;
@@ -52,7 +64,7 @@ type FlowCanvasProps = Omit<ReactFlowProps<FlowNode, Edge>, "nodes" | "edges" |
52
64
  * (xyflow's standard pattern). The surrounding `useFlowState` hook in
53
65
  * `runtime/use-flow-state.ts` is a convenience that wires those for you.
54
66
  */
55
- declare function FlowCanvas({ nodes, edges, background, showControls, showMinimap, height, validateConnections, isValidConnection, colorMode, showHelperLines, onNodesChange, toolbar, nodeTypes, edgeTypes, className, style, ...rest }: FlowCanvasProps): react.JSX.Element;
67
+ declare function FlowCanvas({ nodes, edges, background, showControls, showMinimap, height, validateConnections, isValidConnection, colorMode, showHelperLines, zoomOnWheel, onNodesChange, toolbar, nodeTypes, edgeTypes, className, style, ...rest }: FlowCanvasProps): react.JSX.Element;
56
68
 
57
69
  /**
58
70
  * Clone a set of nodes AND the edges internal to that set, remapping every id.
package/dist/index.d.ts CHANGED
@@ -38,6 +38,18 @@ type FlowCanvasProps = Omit<ReactFlowProps<FlowNode, Edge>, "nodes" | "edges" |
38
38
  validateConnections?: boolean | ConnectionValidatorOptions;
39
39
  /** Show alignment guide lines while dragging, and snap to them. Default off. */
40
40
  showHelperLines?: boolean;
41
+ /**
42
+ * A bare mouse wheel over the canvas zooms it. Default **true**.
43
+ *
44
+ * Turn it off for a canvas embedded mid-page, where a reader scrolling past
45
+ * would otherwise get trapped zooming. With it off the wheel scrolls the page
46
+ * and **Shift+wheel** zooms instead.
47
+ *
48
+ * Either way, a wheel gesture that zooms never also scrolls the page — the
49
+ * two happening at once is the thing that makes an embedded canvas feel
50
+ * broken.
51
+ */
52
+ zoomOnWheel?: boolean;
41
53
  /** Optional toolbar / palette etc. rendered above the canvas. */
42
54
  toolbar?: ReactNode;
43
55
  className?: string;
@@ -52,7 +64,7 @@ type FlowCanvasProps = Omit<ReactFlowProps<FlowNode, Edge>, "nodes" | "edges" |
52
64
  * (xyflow's standard pattern). The surrounding `useFlowState` hook in
53
65
  * `runtime/use-flow-state.ts` is a convenience that wires those for you.
54
66
  */
55
- declare function FlowCanvas({ nodes, edges, background, showControls, showMinimap, height, validateConnections, isValidConnection, colorMode, showHelperLines, onNodesChange, toolbar, nodeTypes, edgeTypes, className, style, ...rest }: FlowCanvasProps): react.JSX.Element;
67
+ declare function FlowCanvas({ nodes, edges, background, showControls, showMinimap, height, validateConnections, isValidConnection, colorMode, showHelperLines, zoomOnWheel, onNodesChange, toolbar, nodeTypes, edgeTypes, className, style, ...rest }: FlowCanvasProps): react.JSX.Element;
56
68
 
57
69
  /**
58
70
  * Clone a set of nodes AND the edges internal to that set, remapping every id.
package/dist/index.js CHANGED
@@ -357,6 +357,16 @@ function HelperLines({ horizontal, vertical }) {
357
357
  )
358
358
  ] });
359
359
  }
360
+ function preventScrollWhileZooming(event) {
361
+ if (event.shiftKey) event.preventDefault();
362
+ }
363
+ function wheelZoomProps(zoomOnWheel) {
364
+ return zoomOnWheel ? { zoomActivationKeyCode: null, preventScrolling: true } : {
365
+ zoomActivationKeyCode: "Shift",
366
+ preventScrolling: false,
367
+ onWheelCapture: preventScrollWhileZooming
368
+ };
369
+ }
360
370
  var DEFAULT_FIT_VIEW = { padding: 0.2 };
361
371
  var DEFAULT_EDGE_OPTIONS = {
362
372
  type: "smoothstep",
@@ -373,6 +383,7 @@ function FlowCanvas({
373
383
  isValidConnection,
374
384
  colorMode,
375
385
  showHelperLines = false,
386
+ zoomOnWheel = true,
376
387
  onNodesChange,
377
388
  toolbar,
378
389
  nodeTypes,
@@ -445,8 +456,7 @@ function FlowCanvas({
445
456
  fitViewOptions: DEFAULT_FIT_VIEW,
446
457
  defaultEdgeOptions: DEFAULT_EDGE_OPTIONS,
447
458
  proOptions: { hideAttribution: true },
448
- zoomActivationKeyCode: "Shift",
449
- preventScrolling: false,
459
+ ...wheelZoomProps(zoomOnWheel),
450
460
  isValidConnection: resolvedIsValidConnection,
451
461
  ...rest,
452
462
  children: [