forked from ZjuulOWOW/motion-playground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransition2.js
63 lines (60 loc) · 2.25 KB
/
transition2.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import barba from '@barba/core'
var inTransition = true
barba.init({
debug: true,
preventRunning: true,
transitions: [{
sync: true,
leave({current}) {
return new Promise(resolve => {
current.container.animate(
{
transform: 'translate3D(0,-100vh,0) scale(.8)', //translate3D depending on direction
filter: 'brightness(0)'
},
{
duration: 1600,
fill: 'forwards',
easing: 'linear'
}).onfinish = () => resolve()
})
},
afterLeave({current}) {
current.container.remove()
},
enter({next}) {
return new Promise(resolve => {
const clip = next.container.querySelector('.clip')
const title = next.container.querySelector('.title')
clip.classList.add('is-transitioning')
title.classList.add('is-transitioning')
next.container.animate({
transform: ['translate3D(0,100vh,0)', 'translate3D(0,0,0)'], //translate3D depending on direction
},
{
duration: 400,
fill: 'forwards',
easing: 'cubic-bezier(0,1,1,1)'
}).onfinish = () => {
clip.animate({
maxHeight: [0, '200px']
},
{
duration: 600,
fill: 'forwards',
easing: 'cubic-bezier(0,1,1,1)'
}).onfinish = () => {
title.animate({
transform: ['translate3D(0, 100%, 0)', 'translate3D(0, 0, 0)'],
},
{
duration: 800,
fill: 'forwards',
easing: 'cubic-bezier(0,1,1,1)'
}).onfinish = () => resolve()
}
}
})
}
}]
})