Skip to content

from-[route] class #368

Answered by scsskid
scsskid asked this question in Help
Discussion options

You must be logged in to vote

Update: there is now an official Route Name Plugin that does this automatically.

Previous answer:

I managed to achieve this with events:

It works somehow, but I'm struggling to figure out how and when to change transition timings, especially delays

# use classifyHelper
import { classify } from "swup/lib/helpers";

const docEl = document.documentElement;

swup.on("animationOutDone", () => {
  const routeFrom =
    swup.transition.from !== "/" ? swup.transition.from : "homepage";
  const fromClassName = `from-${classify(routeFrom)}`;
  docEl.classList.add(fromClassName);
});

swup.on("animationInStart", () => {
  const getStartsWithFromClassName = (className) => {
    return className.start…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by scsskid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant