Webflow Page Transitions
This skill covers how to work with the Taxi.js transition system and how it triggers module lifecycles.
Taxi is opt-in
Taxi is off in the template: it is commented out in src/app.ts and src/lib/pages.ts. Links are full page loads, so onDestroy and onPageOut never run. onPageIn and onMount run once per load.
The steps to enable it (uncommenting in src/lib/pages.ts and src/app.ts, the data-taxi and data-taxi-view markup, and "taxi": true in checks.config.json) are in one place: Integration with Taxi.js. Taxi throws without data-taxi-view on the page content.
How it Works (once enabled)
- Trigger: User clicks a valid link.
- Leave: Taxi calls
onLeave->transitionOut->onPageOuthooks run -> modules destroyed (onDestroy). - Load: New content is fetched and swapped.
- Enter: Taxi calls
onEnter->transitionIn-> modules initialized ->onPageInhooks run ->onMounthooks run.
Implementing Transitions in Modules
Use the onPageIn and onPageOut hooks inside your modules to create seamless transitions. They are safe to write before Taxi is on: onPageIn runs on load, and onPageOut waits until it is enabled.
import { onEditor, onPageIn, onPageOut } from "@/modules/_";
import gsap from "@lib/gsap";
export default function (element: HTMLElement) {
let inEditor = false;
onEditor((isEditor) => {
inEditor = isEditor;
});
// Entrance animation
onPageIn(async () => {
if (inEditor) return;
await gsap.from(element, {
opacity: 0,
y: 30,
duration: 1,
ease: "power3.out",
});
});
// Exit animation
onPageOut(
async () => {
await gsap.to(element, {
opacity: 0,
duration: 0.5,
});
},
{ element }
); // { element } ensures it only runs if visible
}
Global Configuration
Transitions are managed in src/lib/pages.ts and src/lib/page-transitions.ts. You can ignore specific links by adding data-taxi-ignore to the link in Webflow.
Troubleshooting Transitions
- Nothing happens on navigation: Taxi is off until the steps above are done.
- Animations not waiting: Ensure your lifecycle hooks return a
Promise(useasyncandawait). - Module not mounting on new page: Check if
data-moduleis present in the new page's HTML and that the filename matches exactly. - Scroll issues: The system automatically scrolls to top in
transitionOut. - Memory leaks: Ensure
onDestroyhandles cleanup; it is triggered by the transition system once Taxi is on (see House Rules).