igs
igs

Reputation: 41

How do I cancel ViewTransitions API animations?

I cant seem to figure out how to cancel/bail on view transitions depending on clicked link type. I would like to have the following:

index -> project - should transition

works -> project - should transition

index -> works - should not transiton

I have the following function but it does not prevent the transition for certain target destinations:

function updateView(event) {
const restrictedPages = ["works.php", "index.php", "services.php"];
if (restrictedPages.includes(event.target.href.split('.')[0])) { 
document.startViewTransition(() => {}).skipTransition(); }
}

Has anybody figured out how to bail out of transitions with the API?

Upvotes: 3

Views: 126

Answers (0)

Related Questions