Pre-commit lint hook had made the use of ternaries harder to read
than I'd originally intended so I introduced an additional
variable which explains what is being checked and keeps ternaries
from becoming obscured.
Based on review by @nirname. I had originally been trying
to minimise number of new arguments being passed to
rerouting check but as the branch curve check is not used
elsewhere and is part of the same rerouting check it makes
sense for them to be together.
Position information now passed to rerouting fn instead.
Hypothesised that working out which branch needed checking for
overlapping commits might be missing, so added that as a
nested ternary and passed result as new argument to rerouting
check.
If commits are found on the branch which will be getting the
curve (whichever branch is lower or more to the right of main
than the other, for now), then the arrow will be rerouted.
I may refactor in a follow-up commit and I think there's scope
to simplify the logic but this is a test for now.
Checking if branch was same as main turned out to be redundant
for now, since there don't seem to be any cases where routing
curves into main.
This fixes issue found in review by @nirname and avoids a
situation where branching from the same commit results in
unnecessary rerouting.
The function also now does an additional check to see
if source branch in overlap check is on main.
As we're no longer purely checking for an overlap and
the only use of this function is to reroute the arrows
to avoid running over commits, this more literal name
should be clearer.
On previous rewrite, I had created new functions within the
overlapping functions but these were being recreated on each
iteration of Object.some(). I moved them outside this for
clarity and so they're not recreated each iteration.
Changed argument names from commit1 and commit2 to
commitA and commitB respectively to prevent confusion
with seq number values.
Replaced Array filter method with array some method
so that as soon as one overlap is found, function is
finished.
Used Object.entries instead of Object.keys to reduce
number of variables needed and make function easier
to read.
Originally, the function was checking if any commits were on the
same branch as `commit2`, the destination commit.
However, in order to avoid a conflict, we should only need to
check whether any commits are on the same branch as `commit 1`.
Updated and moved commenting as well.
Position the tooltip centered, just below the node being hovered.
Update packages/mermaid/src/diagrams/flowchart/flowDb.js
Co-authored-by: Sidharth Vinod <sidharthv96@gmail.com>
window.scrollY is already account for which means document.body.scrollTop incorrectly offsets the tooltip vertically.
The same is not true for horizontal position.