-
Hi there! I'm facing some doubts using the new Swup/Astro and Parallel Plugin. I was using using Swup in my Astro project via astro.config.mjs and everything was working fine with my Parallel plugin but I need another transitions in other pages and handle some javascript after page transition.
After try manual swup setup and install and set the configuration as I had it in my Astro config, everything was working fine until I installed SwupJsPlugin. When I installed it, the Parallel transitions were not working and it was like SwupJsPlugin was overriding them. Is there any way to handle this and use both plugins? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 6 replies
-
Hey 🏓 If you need different transitions for different pages, I'd suggest using the integration's routes option and then differentiate based on the route you're going from or to. To disable parallel animations on specific visits, you can do so in a hook. See this example in the docs. There's also mentions of people using GSAP with the parallel plugin, so it should in theory work just fine. However, I can't point you to concrete examples as it's not something we tried. Lastly, if you really do need to use GSAP and the JS plugin, the way to go is definitely manual setup. The astro integration tries to cover the 80% use case; running your own animations is a perfect candidate for "ejecting" from the integration, so to say. |
Beta Was this translation helpful? Give feedback.
-
@Eric-llos I've given it a stab and the combination of JS + Parallel Plugin seems to be working fine. You just need to make sure you're grabbing the correct elements and animating both in the const swup = new Swup({
containers: ['main'],
plugins: [
new SwupParallelPlugin({ containers: ['main'] }),
new SwupJSPlugin({
animations: [
{
from: '(.*)',
to: '(.*)',
in: async () => {
const next = document.querySelector('main');
const prev = document.querySelector('main + main');
await Promise.all([
next.animate([{ opacity: 0, transform: 'translateX(100%)' }, {}], 300).finished,
prev.animate([{}, { opacity: 0, transform: 'translateX(-100%)' }], 300).finished
]);
}
}
]
})
]
}) |
Beta Was this translation helpful? Give feedback.
-
@daun Many thanks! I think I had a bunch of stuff and was hard for me to understand what was happening... Happy to see you can use Parallel and manage the JS animations in JSPlugins :) Thanks <3 |
Beta Was this translation helpful? Give feedback.
-
@daun Hi Philipp, I'm facing some problems (sorry to be such a dumb :') ) with the actual feedback you wrote me. I'll attach a video and a Layout.astro where I create my swup config. ASAP i'll add a demo. The transition I wanted to achieve, its working great: The new page enters from the right side, as you can see in the video: But I'm trying to avoid to scroll to top:0 when I click a link and all the transitions from case-studies or to, start, but there's something missing from my side because I cant achieve it. I've tried inside the animations and with some swup hooks, for example this one: Or even using the ScrollPlugin. Do you have any idea what could I do? The other question is, I think i'm having a problem when the page changes and some part of my components doesnt work. I have a scrollTrigger (gsap) that is not triggering the GSAP animation in my Parallel pages(I think because of the Parallel Plugin). It does not calculate correctly when it should start, so it never starts, but clicking events work correctly. Could it be because the way containers are being attached with Parallel? Do you think is there a way to make a reset or recalculate it after page trasitions? I've tried to reset the scrolltrigger when I mount the component but it does not seems to work.PD: I'll add a demo ASAP Many thanks and Sorry, I'm a bit worried because I've tried a lot of stuff with this two problems but i can't get the correct answer 😢 |
Beta Was this translation helpful? Give feedback.
-
You might solve the scroll issue by disabling scroll reset in a hook. There's an example in the docs: swup.hooks.on('visit:start', (visit) => {
visit.scroll.reset = false;
}); |
Beta Was this translation helpful? Give feedback.
-
@daun I have another doubt! "Out" animation is no longer working in this cases? I'd like to animate something to fullscreen in out and in in, scale it to 0! |
Beta Was this translation helpful? Give feedback.
@Eric-llos I've given it a stab and the combination of JS + Parallel Plugin seems to be working fine. You just need to make sure you're grabbing the correct elements and animating both in the
in
phase of the animation at once: