Link Types!

Want to select a special animation but only for that link from Home to About?

Tell the link about it!

You find such a special link on the Home page of this demo. Clicking it navigates you to the About page with an animation that is different from the one that starts when you click the About link in the header. Press it to see the effect. Then navigate back through the browser history and see yet another animation. This is the HTML for the link on the Home page:

<a href="/signal-demo/link-types/about/" data-vtbag-link-types="flip/turn">very special link</a>

It tells the Turn-Signal component to set the turn view transition type when the link is clicked, and to set flip when doing a history navigation back across that link. For more details visit the @vtbag documentation.

And of course we need some additional CSS for the animations. Other than the previous demos, this one does not use transition:* directives but explicitly provides definitions for all effects. Here is the complete CSS:

@view-transition {
navigation: auto;
}
html body main {
view-transition-name: main;
}
:active-view-transition-type(forward) {
&::view-transition-old(main) {
animation: 0.25s both slide-out-to-left;
}
&::view-transition-new(main) {
animation: 0.25s both slide-in-from-right;
}
}
:active-view-transition-type(backward) {
&::view-transition-old(main) {
animation: 0.25s both slide-out-to-right;
}
&::view-transition-new(main) {
animation: 0.25s both slide-in-from-left;
}
}
:active-view-transition-type(same)::view-transition-image-pair(main) {
animation: 0.25s same;
}
:active-view-transition-type(turn) {
&::view-transition-old(main) {
transform-origin: top;
animation: 0.5s both turn-out;
}
&::view-transition-new(main) {
transform-origin: top;
animation: 0.5s 0.5s both turn-in;
}
}
:active-view-transition-type(flip) {
&::view-transition-old(main) {
animation: 0.25s both flip-out;
}
&::view-transition-new(main) {
animation: 0.25s 0.25s both flip-in;
}
}
@keyframes slide-out-to-left {
to {
transform: translateX(-100%);
}
}
@keyframes slide-out-to-right {
to {
transform: translateX(100%);
}
}
@keyframes slide-in-from-left {
from {
transform: translateX(-100%);
}
}
@keyframes slide-in-from-right {
from {
transform: translateX(100%);
}
}
@keyframes turn-out {
to {
transform: rotateX(90deg);
}
}
@keyframes turn-in {
from {
transform: rotateX(90deg);
}
}
@keyframes flip-out {
to {
transform: rotateY(90deg);
}
}
@keyframes flip-in {
from {
transform: rotateY(90deg);
}
}
@keyframes same {
50% {
transform: scale(0);
}
}

“That’s all folks!” (return to the overview).