Animate an element that is not being replaced #428
-
|
hi, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
You could probably use Swup events to call a transition function in JavaScript. That way, when Swup replaces pages, it runs your code (even if the affected elements aren't being replaced). The Swup docs have a list of the events, but here's some example code. swup.on('contentReplaced', animate); //runs 'animate' every time the content of the page is reloaded. |
Beta Was this translation helpful? Give feedback.
-
|
Swup adds and removes a number of classes on the For example, you might do something like this: .logo {
/* Default positioning styles! */
}
html.is-animating .logo {
/* Styles to apply whenever a navigation is occurring */
}
html.is-leaving .logo {
/* Styles applied when a page is being unloaded */
}You may need to work with these hooks creatively to define the two states for your site (minimized + centered) and ensure the transition only happens under certain circumstances—but the right combination should be available! Check out the "How it Works" page for more info: https://swup.js.org/getting-started/how-it-works |
Beta Was this translation helpful? Give feedback.
Swup adds and removes a number of classes on the
htmlelement that are intended to act as hooks to "cascade" styles anywhere in your document!For example, you might do something like this:
You may need to work with these hooks creatively to define the two states for your site (minimized + centered) and ensure the transition only happens under certain circumstances—but the right combination should be available!
Check out the "How it Works" page for more info: https://swup.js.org…