-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[Enhancement] Modal close animation #436
Comments
I don't have a solution for this yet. |
wdym? why should a page load if I hide a modal? |
@lkj4 currently modal has |
I think it would be better to reopen this and mark it as help wanted some someone else might be able to come up with a solution. |
Agree with @asportnoy. This approach is less compelling without a smooth transition on close. I'm using Sveltekit and will probably have to migrate to something like svelte-simple-modal. Although honestly, I'd prefer to use DaisyUI as much as possible. |
Okay I re-open this but that wouldn't help. We can't animate to |
I'm not great at CSS, but how does svelte-simple-modal implement? |
It applies animation using JS and removes it after showing/hiding modal. |
In solidjs I solved it like this: const Modal: FlowComponent<{ open: boolean }> = (props) => {
const [isVisible, setVisibility] = createSignal(props.open);
createEffect(() => {
if (props.open) {
setVisibility(true);
} else {
setTimeout(function () {
setVisibility(false);
}, 200);
}
});
return (
<div
classList={{
modal: true,
"modal-open": props.open,
"!visible": isVisible(),
}}
>
<div class="modal-box w-1/2 p-20 max-w-none">{props.children}</div>
</div>
);
};
`` |
What if we include a hint and maybe some quick vanilla js example "Modal with close animation" just in the Daisyui docs. That way users would see that they have to do something with js & that this behavior is intended! |
I'm definitely for adding a JS tab like the html tab for examples that require js to function properly. |
The closing animation is working as expected after I made the modal visible by default with Is there any hidden behavior that I'm not aware of? |
Maybe the modal CSS closing animation could be realized by using a transition-delay on
PS: Thx for explaining the issue with the closing modal animation, and also all the work you put into this @saadeghi. |
PR #1335 I was able to add smooth modal closing transitions by simple adding modal.mov |
PR added, this should finally fix this issue. On a side-note: A few months ago I also thought JS to be the answer for most interactivity, but since using |
Can this be added for toasts too? |
@MarcGodard unfortunately no. HTML elements can use a CSS animation when being added to the page but when we remove them from the page, they will be removed instantly, so there's no way for CSS to run an animation before the node is being removed. To achieve this, you can manually add a style (could be You can also use a JS animation library for that. Or if your framework has animation functions (like Svelte) you can use them |
Modals have an animation for opening, but closing just happens instantly with no animation. It would be nice to have a closing animation, potentially just the opening animation in reverse.
This also occurs on the docs so I know it is not an issue with my code.
The text was updated successfully, but these errors were encountered: