Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var width = 740;
- var animationSpeed = 1000;
- var pause = 3000;
- var currentSlide = 1;
- var interval;
- var timer;
- function slide() {
- timer = function () {
- interval = setInterval(function () {
- if(currentSlide === $("#slides").children().length) width = 0;
- else width = 740;
- $("#slides").animate({'margin-left': '-=' + width}, animationSpeed, function () {
- if (++currentSlide > $("#slides").children().length) {
- currentSlide = 1;
- $("#slides").animate({'margin-left': 0}, animationSpeed);
- clearInterval(interval);
- timer();
- }
- });
- }, pause);
- }
- }
- function next() {
- console.log("Going forward:" + currentSlide,$("#slides").children().length - 1);
- if (currentSlide <= $("#slides").children().length - 1) {
- $("#slides").animate({'margin-left': '-=' + width}, animationSpeed, function () {
- currentSlide += 1;
- });
- clearInterval(interval);
- timer();
- }
- }
- function previous() {
- console.log("Going back:" + currentSlide,$("#slides").children().length - 1);
- if (currentSlide >= $("#slides").children().length - 1) {
- $("#slides").animate({'margin-left': '+=' + width}, animationSpeed, function () {
- currentSlide -= 1;
- });
- clearInterval(interval);
- timer();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement