-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.js
More file actions
32 lines (30 loc) · 796 Bytes
/
controller.js
File metadata and controls
32 lines (30 loc) · 796 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
(function () {
var current = 0;
var max = 0;
var container;
function init() {
container = jQuery(".slide ul");
max = container.children().length;
console.log("init");
events();
}
function events() {
jQuery("button.prev").on("click", prev);
jQuery("button.next").on("click", next);
}
function prev( e ) {
current--;
if (current < 0) current = 0;
animate();
}
function next( e ) {
current++;
if (current > max-1) current = max-1;
animate();
}
function animate() {
var moveX = current * 450;
TweenMax.to(container, 0.8, { marginLeft: -moveX,ease: Expo.easeOut });
}
jQuery(document).ready(init);
})();