-
Notifications
You must be signed in to change notification settings - Fork 337
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
Feature: configurable dismiss timer duration #89
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/timo/react-hot-toast/BxJ7hRyCg1dWRkn95eMrx2hw14pH |
Updated the docs too now :) |
I use react-hot-toast in headless mode and handle the animation with framer-motion, this option will be really useful to be able to dismiss the toast instantly and let framer-motion remove it with AnimatePresence |
Thanks a lot for this PR, @nfuad. Much appreciated. Also thanks to @efflam for clarifying why this is needed. One thing I'd like to change before merging is renaming the option to Edit: One more thought on the docs: I'd assume that (if you're using headless-mode + framer-motion) you'd want to extend the delay for all toasts, not just one. Maybe showing how to apply to all via the Toaster would be a more fitting example. |
Thank you, @efflam for clarifying the use case. In my case though, I just want to show an exit animation that is less than 1 second. |
Thanks a lot! I'll review the PR shorty. @nfuad Because you mentioned you need this for shorter animations: The default exit animation is also just 0.4s long. You can preserve the final state of the animation by using |
@timolins, ah yeah, that would work as well. Thanks for letting me know :) |
It will be merged someday? Why it's still open? |
This would be a useful addition. The current default makes it feel a little unresponsive for the user. |
@nfuad I'm new to open source. Please can you provide me a setup guide I will like to contribute. When I tried in my local the src is getting bundled and after running sites, it is picking from dist. |
is this going to me merged soon? Would be really helpful. |
would love to see this PR merged :) |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@cquanu I'm not sure if I can see why the vercel build is failing - please feel free to take over and merge the PR. |
@nfuad Sorry I'm not the maintainer - won't be able to do this. |
For now, I was able to somewhat do this by calling My close button looks like this:
Note that this will only work if the animation duration is less than the default of 1 second. Also not sure if this works with |
Move them outside of the main store and into the useToaster
Picked this PR up again – thanks, everyone, for their patience. There was a bug where the options weren't respected when they were supplied to the Toaster itself. This was caused by some side effects, which should live outside the store, so I used this PR for a small refactor that I had wanted to do for quite some time. Merging now! |
The dismiss operation had a hardcoded delay value of 1000 milliseconds which was not configurable. Made some changes to the
store.ts
file so that a value for the dismiss delay could be passed like so:*Also added the new type to the associated
types.ts
file.Closes issue #74
These are non-breaking changes (backward-compatible)