-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·57 lines (48 loc) · 1.33 KB
/
index.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
$(document).ready(function(){
if ('ontouchstart' in document.documentElement) {
$('html').addClass('touch');
$('.gallery').bind('click', function(e) {
e.preventDefault();
$(this).children().each(function() {
let index = $(this).css('z-index');
if (index < 3) {
index++;
} else {
index = 1;
}
$(this).css('z-index', index);
});
});
} else {
hoverx = 8;
$('.intro h2 span').mouseover(function(event) {
hoverg = mouseX(event, $(this));
$('.aboutimage').animate({'opacity': 1}, 75);
}).mouseleave(function(event) {
$('.aboutimage').animate({'opacity': 0}, 150);
});
$('.intro h2 span').mousemove(function(event) {
var x = mouseX(event, $(this));
if (x > hoverg) {
hoverx -= 1;
hoverg = x;
} else if (x < hoverg) {
hoverx += 1;
hoverg = x;
}
if (hoverx < 0) {
hoverx = 0;
} else if (hoverx > 18) {
hoverx = 18;
}
$('.aboutimage').css({'background-position': (hoverx * -1 * $('.aboutimage').width())});
});
$(window).resize(function(event) {
$('.aboutimage').css({'background-position': (hoverx * -1 * $('.aboutimage').width())});
});
$('.aboutimage').css('background-image', 'url("assets/images/me.jpg")');
}
});
function mouseX(event, that) {
return (Math.floor((event.pageX - that.offset().left) / that.width() * 18)) - 1;
}