-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
60 lines (58 loc) · 1.08 KB
/
main.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
const pageScroller = new PageScroller('page-container', 200);
pageScroller.set({
easingForAll: {
func: "easeOutQuart",
},
easing: [
{
from: '1',
to: '0',
func: 'linearTween'
},
{
from: '2',
// to: '2',
func: 'easeInOutQuart',
}
],
actionOn: [
{
pageIndex: "1",
action: () => {
console.log('This could be an animation happening on section 1.')
},
}
],
reset: 'true',
dragTreshold: 0.2,
whileTransitioning: [
{
from: '0',
to: '1',
callback: () => console.log('This happens while transitioning from section 1 to 0.'),
},
{
from: '2',
// to: '1',
callback: () => console.log('This happens while transitioning from section 2.'),
}
],
beforeTransitioning: [
{
from: '1',
to: '0',
callback: () => {
return new Promise((resolve) => {
console.log('This is before the transition from 0 to 1.')
setTimeout(() => {
resolve();
},3000)
});
},
},
]
});
const toTopBtn = document.getElementById('to-top-btn');
toTopBtn.addEventListener('click', () => {
pageScroller.scrollToPage(0);
});