forked from soumita1234/HelpingHand
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
47 lines (36 loc) · 1.18 KB
/
app.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
var btn = $('#button');
$(window).scroll(function () {
if ($(window).scrollTop() > 300) {
btn.addClass('show');
} else {
btn.removeClass('show');
}
});
btn.on('click', function (e) {
e.preventDefault();
$('html, body').animate({
scrollTop: 0
}, '300');
});
AOS.init();
// Contact : PNG illustration
let el = document.querySelector('.avatar')
el.addEventListener('mousemove', (e) => {
let thisPX = el.getBoundingClientRect().left
let thisPY = el.getBoundingClientRect().top
let boxWidth = el.getBoundingClientRect().width
let boxHeight = el.getBoundingClientRect().height
let scrollTop = document.documentElement.scrollTop + document.body.scrollTop
let mouseX = e.pageX - thisPX
let mouseY = e.pageY - scrollTop - thisPY
let X
let Y
X = mouseX - boxWidth / 2
Y = boxHeight / 2 - mouseY
el.style.transform = `perspective(300px) rotateY(${X / 10}deg) rotateX(${Y / 10}deg)`
el.style.boxShadow = `${-X / 20}px ${Y / 20}px 50px rgba(0, 0, 0, 0.3)`
})
el.addEventListener('mouseleave', () => {
el.style.transform = `perspective(300px) rotateY(0deg) rotateX(0deg`
el.style.boxShadow = ''
})