github xyflow/xyflow 7.0.0
Release 7.0.0

latest releases: 11.11.2, reactflow@11.11.2, @reactflow/node-toolbar@1.3.12...
3 years ago

Breaking Changes

  • Nodes with multiple handles are now treated differently: Before, we used a combination of the nodeId and the handleId as target or source property (e.g. nodeId__handleId). This has been now split into two properties: target/source (same as before) and targetHandle/sourceHandle. This makes it easier and cleaner to work with multiple handles and connections between them. If you have used multiple handles before, you might have to edit your onConnect method and add a new edge with the new properties. Thanks to @jasonpul and @nadenf for working on this!

Example Code:

// lets say we have 2 nodes, one input node with a source handle and a custom node with two target handles which have the ids a and b
// our goal is to have a connection from the input node to each of the target handles of the custom node
const nodes = [
  { id: '1', type: 'input', data: { label: 'Node with one source handle' } },
  {
    id: '2',
    type: 'multiHandleNode',
    data: { label: 'This node contains 2 handles with ids a and b' },
  },
];

// in v6 and below we only had the target property to tell react-flow which handle is connected
// this has been done using __ in the target id
const elementsV6 = [
  ...nodes,
  {
    id: 'e1-2a',
    source: '1',
    target: '2__a', // targetNode 2, targetHandle a
  },
  {
    id: 'e1-2a',
    source: '1',
    target: '2__b', // targetNode 2, targetHandle b
  },
];

// from v7 onwards we can use the targetHandle/sourceHandle properties to define which handle the edge is connecting exactly
const elementsV7 = [
  ...nodes,
  {
    id: 'e1-2a',
    source: '1',
    target: '2',
    targetHandle: 'a',
  },
  {
    id: 'e1-2a',
    source: '1',
    target: '2',
    targetHandle: 'b',
  },
];

New Features

  • panOnScroll property: The library now supports panning with the mousewheel or trackpad. This can be used instead of the default behaviour which uses the mousewheel to zoom the canvas
  • panOnScrollSpeed property: New property that can be used in combination with the panOnScroll option to control the speed the movement

Website

Don't miss a new xyflow release

NewReleases is sending notifications on new releases.