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

feat: toaster's dynamic exitDuration #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

uceumice
Copy link

Make the duration it takes for a Toast to leave configurable.

Make the duration it takes for a `Toast` to leave configurable.
@GrandSchtroumpf
Copy link
Owner

GrandSchtroumpf commented Jul 16, 2023

Thanks for the PR, the main issue here is that you need to update the animation duration also.
It could be done with a css variable that is set in the style tag for example (you can use the cssvar method)

@uceumice
Copy link
Author

Thanks for the PR, the main issue here is that you need to update the animation duration also. It could be done with a css variable that is set in the style tag for example (you can use the cssvar method)

Ah, alright, I will have a closer look and try to rewrite it with cssvar.

@GrandSchtroumpf
Copy link
Owner

@uceumice I think I found a better solution. Using the addEventListener('animationend', cb) I can have only one source of truth:

// Use event "animationend" instead of timeout
ref.value.addEventListener('animationend', remove}, { once: true })

Like that you can customize it with a css variable :

:root {
  --toaster-closing-duration: 500ms;
}
/* Or */
.my-customer-toaster {
  --toaster-closing-duration: 500ms;
}

What do you think ?

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

Successfully merging this pull request may close these issues.

2 participants