-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathhome.js
42 lines (39 loc) · 1.31 KB
/
home.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
(async ({ worker, delay, Waypoint, alert }) => {
var homeContent = document.querySelector('#homeContent')
var animatableComponents = homeContent.querySelectorAll('animatable-component')
function initialize () {
homeContent.style.display = 'block'
var innerScroll = homeContent.shadowRoot.querySelector('.inner-scroll')
animatableComponents.forEach(function (component, index) {
var element = component.querySelector(':first-child')
component.delay = index * 200
component.autoPlay = true
component.waypoint = new Waypoint({
context: innerScroll,
offset: '26%',
element: element,
handler: function (direction) {
if (component.classList.contains('projects')) {
if (direction === 'down') {
component.duration = 400
component.animation = 'pulse'
} else {
component.duration = 800
component.animation = 'bounce'
}
}
component.delay = 100
component.finish()
component.play()
}
})
})
}
function detectWokerEvent (e) {
if (e.data === 'homeStart') {
worker.removeEventListener('message', detectWokerEvent)
initialize()
}
}
worker.addEventListener('message', detectWokerEvent)
})(window)