-
-
Notifications
You must be signed in to change notification settings - Fork 474
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
Check if link has been prefetched successfully #568
Comments
Hi @TheFunkyMonk, Thanks for opening the issue. Have a nice day 😉 |
Thanks @xavierfoucrier! For clarity around what I'm asking, here is a workaround I've come up with that seems to work ok: const initBarba = () => {
let cachedPages = [];
barba.use(barbaPrefetch);
barba.init({
transitions: [
{
before: (data) => {
barba.cache.getRequest(data.trigger.href).then(() => {
cachedPages.push(data.trigger.href);
});
},
leave: (data) => {
const showLoader = !cachedPages.includes(data.trigger.href);
if (showLoader) {
// Pause lifecycle to animate in loader
}
},
enter: (data) => {
// Pause lifecycle to animate in new page
}
}
]
});
} Basically, in the It would be nice if |
@TheFunkyMonk Hi 👋 Sorry for the long long reply... I will work on this soon, and I wanted to let you know that there are currently two possibilities for your use case:
let request;
barba.init({
transitions: [{
name: 'opacity-transition',
before(data) {
request = barba.cache.getRequest(data.next.url.href);
},
leave(data) {
return request.then(() => {
gsap.to(data.current.container, {
opacity: 0
});
});
},
enter(data) {
return gsap.from(data.next.container, {
opacity: 0
});
},
}],
});
barba.init({
transitions: [{
name: 'opacity-transition',
sync: true,
leave(data) {
return gsap.to(data.current.container, {
opacity: 0
});
},
enter(data) {
return gsap.from(data.next.container, {
opacity: 0
});
},
}],
}); Hope this is clear 😉 |
Closed by #704. |
When using the @barba/prefetch plugin, new pages are usually ready to go before they're clicked on and I can transition them in. In the event they aren't ready, I would like to animate in a loading spinner so the user isn't left without feedback (though this should be bypassed if not needed).
Something like:
It seems the only way to currently do something similar to this would be to always trigger the entrance of the loading spinner in the
before
hook, and let the entrance of the new page fade in over the top of it, effectively obscuring it from view if it's not needed.Though this sometimes leads to odd occurrences where the enter hook is ready to fire when the loader entrance has partially completed, so the user just sees a brief flash of the loader. It would be nice if the lifecycle progress could he halted for an animation in the
before
hook only if the prefetch hasn't completed yet.The text was updated successfully, but these errors were encountered: