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

Is there a way on mouse leave return to initial position? #64

Closed
theexplay opened this issue Feb 19, 2022 · 3 comments
Closed

Is there a way on mouse leave return to initial position? #64

theexplay opened this issue Feb 19, 2022 · 3 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request has workaround Issue has a viable workaround
Milestone

Comments

@theexplay
Copy link

Hello, Is there a way on mouse leave return to initial position? It would be great if there was an API like this.

Now i'm using react key to rerender on mouse leave

@nerdyman
Copy link
Owner

nerdyman commented Feb 20, 2022

Hey @theexplay, thanks for opening the issue!

It's not currently possible to reset the position back to the original from the parent due to how prop updates are handled, but it's definitely a valid use case.

Using a key is probably the best way to do it for now, or set it to something like 50.0001, but I'm open to suggestions on how to achieve it without hacks.

I was thinking of exposing the updateInternalPosition function to the parent using a hook or ref but haven't decided on the best approach yet. It might also be possible to refactor the logic in the link above to respect the parent position but I don't think the useEffect will be triggered if the position prop passed to the parent on mouse leave is the same value as the current position.

@nerdyman nerdyman added the enhancement New feature or request label Feb 20, 2022
@theexplay
Copy link
Author

I like the idea of providing api updateInternalPosition via ref

@nerdyman nerdyman added this to the v3 milestone Oct 5, 2022
@nerdyman nerdyman added the has workaround Issue has a viable workaround label Dec 13, 2022
@nerdyman nerdyman added awaiting release documentation Improvements or additions to documentation labels Apr 1, 2023
@nerdyman
Copy link
Owner

nerdyman commented Oct 29, 2023

This has been released in v3!

See the reset on pointer leave and useReactCompareSliderRef examples for usage.

npm install react-compare-slider@latest
yarn add react-compare-slider@latest
pnpm install react-compare-slider@latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request has workaround Issue has a viable workaround
Projects
No open projects
Development

No branches or pull requests

2 participants