| 1 |
import type Swup from '../Swup.js'; |
| 2 |
import { nextTick } from '../utils.js'; |
| 3 |
import type { Visit } from './Visit.js'; |
| 4 |
|
| 5 |
/** |
| 6 |
* Perform the in/enter animation of the next page. |
| 7 |
* @returns Promise<void> |
| 8 |
*/ |
| 9 |
export const animatePageIn = async function (this: Swup, visit: Visit) { |
| 10 |
// Check if failed/aborted in the meantime |
| 11 |
if (visit.done) return; |
| 12 |
|
| 13 |
const animation = this.hooks.call( |
| 14 |
'animation:in:await', |
| 15 |
visit, |
| 16 |
{ skip: false }, |
| 17 |
(visit, { skip }) => { |
| 18 |
if (skip) return; |
| 19 |
return this.awaitAnimations({ selector: visit.animation.selector }); |
| 20 |
} |
| 21 |
); |
| 22 |
|
| 23 |
await nextTick(); |
| 24 |
|
| 25 |
await this.hooks.call('animation:in:start', visit, undefined, () => { |
| 26 |
this.classes.remove('is-animating'); |
| 27 |
}); |
| 28 |
|
| 29 |
await animation; |
| 30 |
|
| 31 |
await this.hooks.call('animation:in:end', visit, undefined); |
| 32 |
}; |