MrBlenny / react-flow-chart

🌊 A flexible, stateless, declarative flow chart library for react.

Home Page:https://mrblenny.github.io/react-flow-chart/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Out-of-bounds nodes can break FlowChart

jakubfaliszewski opened this issue · comments

Hi @MrBlenny and everyone!
While working with https://github.com/MrBlenny/react-flow-chart I encountered a problem with disappearing links between nodes. It occurs when nodes are far away from each other or when zoom factor is high enough so nodes are out of bounds. This causes children of InnerCanvas to not be rendered.
It seems that nodesInView that contains of nodes that are only in view was designed to not render unnecessary nodes due to the performance issues, but it creates some problems. When nodes are removed links between them cannot exist which leads to hiding links that should be visible and to rendering errors.

Problem

Links that should be visible can be hidden because nodes are removed when they are positioned out of bounds.
Demo - here you can see that links disappears after zooming in and everything goes wild after zooming out:
demo

Solution

I propose two solutions here:

  • allowing to remove filtering of out of bounds nodes by additional configuration - if new prop is set to true nodesInView will be just Object.keys(nodes)
  • not removing nodes at all, just use some CSS styling to reduce performance impact (maybe visibility: hidden will do the job)