forked from ZjuulOWOW/motion-playground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transition4.js
43 lines (40 loc) · 1.26 KB
/
transition4.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import barba from '@barba/core'
import gsap from 'gsap'
const el = document.createElement('div')
el.setAttribute('id', 'transition')
document.body.prepend(el)
barba.init({
debug: true,
transitions: [{
leave() {
return new Promise(resolve => {
el.classList.add('is-active')
el.animate(
{
transform: ['translate3D(0,100vh,0)', 'translate3D(0,0,0)'], //translate3D depending on direction
},
{
duration: 300,
fill: 'forwards',
}).onfinish = () => resolve()
})
},
afterLeave({current}) {
current.container.remove()
},
enter() {
return new Promise(resolve => {
el.animate({
transform: ['translate3D(0,0,0)', 'translate3D(0,-100vh,0)'], //translate3D depending on direction
},
{
duration: 300,
fill: 'forwards',
}).onfinish = () => {
el.classList.remove('is-active')
resolve()
}
})
}
}]
})