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

not referring the elements when scrolling time. it is stick at the browser #133

Open
RajasekharReddy82 opened this issue Mar 31, 2022 · 3 comments

Comments

@RajasekharReddy82
Copy link

RajasekharReddy82 commented Mar 31, 2022

Describe the bug & Expected behavior
A clear and concise description of what the bug is.
passed id to xarrows its is working good but when i am trying to scroll it is not scrolling for that element it fixed at same position and i am using positons relative and absolute in my components not using any fixed positions.

To Reproduce
Steps to reproduce the bug: what props where used, in what way the lib was used?
provide preferably minimal code snippets/codesandbox/gitpod.

Screenshots
If applicable, add screenshots to help explain your problem.
image

@stoney95
Copy link

I am facing the same issue. @RajasekharReddy82 did you already find a way to resolve this?

I took a screenrecording with the example from the ReadMe. In Mozilla Firefox and Chrome it looks like this:
https://user-images.githubusercontent.com/34100018/162848286-002e7e5f-f9fe-40cb-8ea6-3ad56b8cfac7.mov

@stoney95
Copy link

@RajasekharReddy82 I could fix my problem, I will share in case it is relevant for you too. I tried before with something like this:

import Xarrow, {useXarrow, Xwrapper} from 'react-xarrows';

const SomeComponent = () => {
     const updateXArrow = useXarrow();

     useEffect(() => {
        window.addEventListener("scroll", updateXArrow)
        return () => window.removeEventListener("scroll", updateXArrow)
    })

    return (<div className="container">
        <Xwrapper>
            <Draggable onDrag={updateXArrow}><div id="elem1">element 5</div></Draggable>
            <Draggable onDrag={updateXArrow}><div id="elem2">element 6</div></Draggable>
            <Xarrow start="elem1" end="elem2"/>
        </Xwrapper>
    </div>)
};

The problem for me was that SomeComponent was placed in a scrollable container itself. This way the event window.scroll was not triggered and thus arrows were not updated. I resolved this by triggering window.scroll when the scrollable container was scrolled. You could also onScroll of the container directly if this suits your use case

@PahanPerera
Copy link

If you set position: "relative" in the container that holds the arrows, It would do the trick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants