-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindexScript.js
65 lines (56 loc) · 1.43 KB
/
indexScript.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
62
63
64
65
$(document).ready(function() {
const $app = $('.app');
const $img = $('.app__img');
const $pageNav1 = $('.pages__item--1');
const $pageNav2 = $('.pages__item--2');
let animation = true;
let curSlide = 1;
let scrolledUp, nextSlide;
let pagination = function(slide, target) {
animation = true;
if (target === undefined) {
nextSlide = scrolledUp ? slide - 1 : slide + 1;
} else {
nextSlide = target;
}
$('.pages__item--' + nextSlide).addClass('page__item-active');
$('.pages__item--' + slide).removeClass('page__item-active');
$app.toggleClass('active');
setTimeout(function() {
animation = false;
}, 3000)
}
let navigateDown = function() {
if (curSlide > 1) return;
scrolledUp = false;
pagination(curSlide);
curSlide++;
}
let navigateUp = function() {
if (curSlide === 1) return;
scrolledUp = true;
pagination(curSlide);
curSlide--;
}
setTimeout(function() {
$app.addClass('initial');
}, 1500);
setTimeout(function() {
animation = false;
}, 4500);
$(document).on('mousewheel DOMMouseScroll', function(e) {
var delta = e.originalEvent.wheelDelta;
if (animation) return;
if (delta > 0 || e.originalEvent.detail < 0) {
navigateUp();
} else {
navigateDown();
}
});
$(document).on("click", ".pages__item:not(.page__item-active)", function() {
if (animation) return;
let target = +$(this).attr('data-target');
pagination(curSlide, target);
curSlide = target;
});
});