-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
46 lines (36 loc) · 960 Bytes
/
script.js
File metadata and controls
46 lines (36 loc) · 960 Bytes
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
"use strict";
$(document).ready(function () {
var slidepos, winwidth, LEFT, RIGHT;
slidepos = 0;
winwidth = $(window).width();
LEFT = -1;
RIGHT = 1;
//Initial Positioning
$("body > div").each(function () {
$(this).show();
$(this).offset({left: slidepos});
slidepos += winwidth;
});
slidepos = 0;
function moveSlider(direction) {
slidepos += direction * winwidth;
if (slidepos < 0) {
slidepos = 0;
}
if (slidepos > $(document).width() - winwidth) {
slidepos = $(document).width() - winwidth;
}
$("body").animate({scrollLeft: slidepos}, 250);
}
$(window).click(function() {
moveSlider(RIGHT);
});
$(window).keydown(function (e) {
if (e.keyCode === 37) {
moveSlider(LEFT);
}
else if (e.keyCode === 39) {
moveSlider(RIGHT);
}
});
});