Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anchor directionality flips to go "short way" #131

Open
larissa-n opened this issue Jan 10, 2021 · 6 comments
Open

Anchor directionality flips to go "short way" #131

larissa-n opened this issue Jan 10, 2021 · 6 comments
Labels
drawing shape enhancement New feature or request

Comments

@larissa-n
Copy link

May be related to #109.

Anchor flips to the opposite side if target is closer to that side. E.g. for targetAnchor: 'left', sourceAnchor: 'right':

Screen Shot 2021-01-10 at 1 24 01 PM

And this is how it shows in react portal (without arrowheads):
Screen Shot 2021-01-10 at 1 24 22 PM

@pierpo
Copy link
Owner

pierpo commented Jan 11, 2021

Hi, thanks for the issue!

Indeed this is related to #109. The library is quite limited right now when it comes to drawing shapes 😞
If you want something that looks good with what the library can provide, you may use targetAnchor: 'top', sourceAnchor: 'bottom'. I hope that's okay with you.

As for the second screenshot, it is related to the other issue that you posted with the portals.

@pierpo pierpo added drawing shape enhancement New feature or request labels Jan 11, 2021
@ivicok
Copy link

ivicok commented Sep 27, 2023

I have a similar issue with side-anchored arrows. A colleague of mine made a tool for displaying relations between words in a sentence, which are mostly top-down tree-like schemes. I wanted to modify it, so that equal-level relations appear as horizontal arrows - bumping into the issue. Unlike top/down-anchored arrows, side-anchors seem to be nudged by style properties (marginLeft/marginRight). When these overlap in calculation of the anchor position, the arrow is reversed. Compare the results with two variants of justifyContent:

Unbenannt2
Unbenannt

@pierpo
Copy link
Owner

pierpo commented Sep 27, 2023

Sorry about that!

However, I think there might be a way to have a workaround in your case. It feels like your elements are not correctly designed!

See how there is a gap between your element and the arrow?
image

That's not normal. You should inspect your page, and you'll notice that your square is probably bigger than you think.

If you solve this, I think the arrow won't be reversed. It happens because two squares are too close to each other.

If you create a code sandbox reproducing this, I can maybe help finding a solution 😊

@ivicok
Copy link

ivicok commented Sep 27, 2023

Thank you for the answer. Yes, it appears, when I define margin for the square box, e.g.:

const boxStyle = { padding: "10px", border: "1px solid #ccc", borderRadius: "4px", fontSize: "12px", marginLeft: "16px", marginRight: "16px" };

When I remove the margin entries from the style definition, the arrow looks well, as long as I use the "space-between" for justifyContent in the style for the row. Editing margin here does not seem to affect the arrow.

const rowStyle = { margin: "100px 10px", display: "flex", justifyContent: "space-between" };

Unbenannt

However, I would rather prefer "center" justification, which is otherwise more neat. I'm just not able to use horizontal arrows. When I define margins, it moves the arrow anchor, as in my first post; when I do not, all the elements are stuffed together like this (ignoring even the 10px defined in rowStyle):

Unbenannt2

@pierpo
Copy link
Owner

pierpo commented Oct 1, 2023

OK! Can you reproduce your example in a codesandbox so that I can play with it? I wonder if it's a styling tweak or if it should an option in the lib.

@ivicok
Copy link

ivicok commented Oct 2, 2023

The script uses PHP-generated variables to work, it does not work in Sandbox at all... But here is the source of the resulting web page (contain links to styles), if it helps - e5-6.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
drawing shape enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants