Last active
December 23, 2015 20:49
-
-
Save JasonCole1980/6691609 to your computer and use it in GitHub Desktop.
Image Rotator script - Built for http://www.mycleanpc.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First round of slideshow function/plugin | |
$(function(){ | |
var rotator = { | |
init: function() { | |
this.buildRotator(); | |
}, | |
slideConfig: { | |
slideWidth: "1024px", | |
slideHeight: "500px", | |
slides: { | |
slide1: { | |
src: "images/rotator-1.jpg?$staticlink$", | |
href: "$url('Page-Show','cid','download-instructions')$" | |
}, | |
slide2: { | |
src: "images/rotator-2.jpg?$staticlink$", | |
href: "$url('Page-Show','cid','download-instructions')$" | |
} | |
} | |
}, | |
buildRotator: function() { | |
var slideConfigObj = this.slideConfig; | |
$("div.image-rotator").html("<ul class='slides'></ul>"); | |
$("ul.slides").css({ | |
"height": slideConfigObj.slideHeight, | |
"width": slideConfigObj.slideWidth | |
}); | |
$.each(slideConfigObj.slides, function(key,valueObj){ | |
var slideItem = '<li><a href="'+ this.href +'"><img src="'+ this.src +'" /></a></li>'; | |
$("ul.slides").append(slideItem); | |
}); | |
$("ul.slides li:first").addClass("visible"); | |
rotator.slideAnimation(); | |
}, | |
slideAnimation: function() { | |
slideVisible = $("ul.slides li.visible"); | |
rotator.fadeSlideOut(); | |
}, | |
fadeSlideOut: function() { | |
$(slideVisible).animate({ | |
opacity: 0, | |
"z-index": 1 | |
}, 5000, function() { | |
if($(this).is(':last-child')){ | |
$("ul.slides li:first-child").addClass("visible").css("z-index", "2"); | |
$(this).removeClass("visible").css("opacity", "1"); | |
} | |
else { | |
$("ul.slides li:last").addClass("visible").css("z-index", "2"); | |
$(this).removeClass("visible").css("opacity", "1"); | |
} | |
setTimeout(rotator.slideAnimation, 4000); | |
}); | |
} | |
} | |
rotator.init(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment