-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
61 lines (52 loc) · 2.04 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
61
document.addEventListener('DOMContentLoaded', function() {
var ripple_wrap = document.querySelector('.ripple-wrap'),
rippler = document.querySelector('.ripple'),
finish = false,
storedcontent,
monitor = function(el) {
var computed = window.getComputedStyle(el, null),
borderwidth = parseInt(computed.getPropertyValue('border-left-width'));
console.log(borderwidth)
if (!finish && borderwidth >= 1500) {
el.style.WebkitAnimationPlayState = "paused";
el.style.animationPlayState = "paused";
swapContent();
}
if (finish) {
el.style.WebkitAnimationPlayState = "running";
el.style.animationPlayState = "running";
return;
} else {
window.requestAnimationFrame(function() {monitor(el)});
}
};
storedcontent = document.getElementById('content-2');
function handleAnimationEnd() {
ripple_wrap.classList.remove('goripple');
}
rippler.addEventListener("webkitAnimationEnd", handleAnimationEnd);
rippler.addEventListener("oAnimationEnd", handleAnimationEnd);
rippler.addEventListener("msAnimationEnd", handleAnimationEnd);
rippler.addEventListener("mozAnimationEnd", handleAnimationEnd);
rippler.addEventListener("animationend", handleAnimationEnd);
document.body.addEventListener('click', function(e) {
if (e.target.tagName.toLowerCase() === 'a') {
rippler.style.left = e.clientX + 'px';
rippler.style.top = e.clientY + 'px';
e.preventDefault();
finish = false;
ripple_wrap.classList.add('goripple');
window.requestAnimationFrame(function() {monitor(rippler)});
}
});
function swapContent() {
if (storedcontent.style.display == "none") {
storedcontent.style.display = "flex";
} else {
storedcontent.style.display = "none";
}
setTimeout(function() {
finish = true;
}, 10);
}
});