summaryrefslogtreecommitdiff
path: root/node_modules/swup/src/modules/animatePageOut.ts
blob: d42bf57f59a826e1d4ec730191bea65e98231eb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import type Swup from '../Swup.js';
import type { Visit } from './Visit.js';

/**
 * Perform the out/leave animation of the current page.
 * @returns Promise<void>
 */
export const animatePageOut = async function (this: Swup, visit: Visit) {
	await this.hooks.call('animation:out:start', visit, undefined, () => {
		this.classes.add('is-changing', 'is-animating', 'is-leaving');
	});

	await this.hooks.call('animation:out:await', visit, { skip: false }, (visit, { skip }) => {
		if (skip) return;
		return this.awaitAnimations({ selector: visit.animation.selector });
	});

	await this.hooks.call('animation:out:end', visit, undefined);
};