-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
executable file
·39 lines (33 loc) · 1.21 KB
/
scripts.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
window.addEventListener('load', function() {
var sliders = document.querySelectorAll('.sliding-pane'),
slidersLeft = sliders.length - 1,
slidingPane = sliders[0],
nextButtons = document.querySelectorAll('.next'),
prevButtons = document.querySelectorAll('.previous');
function iosSlideIn() {
if ( slidersLeft > 0 ) {
slidingPane.classList.add('sliding-pane--hide');
slidingPane.nextElementSibling.classList.add('sliding-pane--slide');
slidingPane = slidingPane.nextElementSibling;
slidersLeft -= 1;
}
prevButtons[0].classList.add('show');
}
function iosSlideOut() {
var hiddenPanes = document.querySelectorAll('.sliding-pane--hide'),
paneToShow = hiddenPanes[ hiddenPanes.length - 1 ];
paneToShow.classList.remove('sliding-pane--hide');
paneToShow.nextElementSibling.classList.remove('sliding-pane--slide');
slidingPane = slidingPane.previousElementSibling;
slidersLeft += 1;
if ( hiddenPanes.length === 1 ) {
prevButtons[0].classList.remove('show');
}
}
for ( var i = 0; i < nextButtons.length; i++ ) {
nextButtons[i].addEventListener('click', iosSlideIn);
}
for ( var ia = 0; ia < prevButtons.length; ia++ ) {
prevButtons[ia].addEventListener('click', iosSlideOut);
}
});