-
Notifications
You must be signed in to change notification settings - Fork 1
/
stopmotion-lite.min.js
11 lines (11 loc) · 1.99 KB
/
stopmotion-lite.min.js
1
2
3
4
5
6
7
8
9
10
11
/*!
* stopmotion-lite.js
* by Ben Byford
*
* Examples and documentation at: http://www.benbyford.com/
* Version: 1.2 (04-MAR-2012)
* Licensed under Creative Commons - Attribution 3.0 Unported (CC BY 3.0).
* http://creativecommons.org/licenses/by/3.0/
* Requires: jQuery v1.2 or later
*/
function stopmotion(a,c,d,b){a=typeof(a)!="undefined"?a:slideImages;c=typeof(c)!="undefined"?c:"100";d=typeof(d)!="undefined"?d:"1";b=typeof(d)!="undefined"?b:"0";if(d=="1"){$(a).parent().prepend('<div id="playPause"></div>')}if(b=="1"){$(a).parent().prepend('<a id="slideBack" href="#">‹</a><a id="slideForward" href="#">›</a>')}$(a).children().css("position","absolute");$(a).find(":first-child").addClass("slideOn firstSlide");$(a).find(":last-child").addClass("lastSlide");$imgNum=$(a).children().length;$i="0";$(window).load(function(){$a="0";$pause="0";$("#playPause").css("display","block").bind("click",function(){if($a=="0"){$(this).css("background-position","0px -20px");$a="1";$pause="1"}else{$(this).css("background-position","0px 0px");$a="0";$pause="0";g()}});$(a).animate({opacity:1},500,h);$("#slideForward").bind("click",function(){e()});$("#slideBack").bind("click",function(){i()});function f(){$(".slideOn").css("display","none").css("z-index","0").removeClass("slideOn").next().addClass("slideOn").css("z-index",$imgNum).css("display","block");if($i==$imgNum){$i="1";$(".firstSlide").addClass("slideOn")}else{$i++}g()}function g(){if($pause=="0"){var j=setTimeout(f,c)}else{}}function e(){$(".slideOn").css("display","none").css("z-index","0").removeClass("slideOn").next().addClass("slideOn").css("z-index",$imgNum).css("display","block");if($i==$imgNum){$i="1";$(".firstSlide").addClass("slideOn")}else{$i++}}function i(){$(".slideOn").css("display","none").css("z-index","0").removeClass("slideOn").prev().addClass("slideOn").css("z-index",$imgNum).css("display","block");if($i=="1"){$i=$imgNum;$(".lastSlide").addClass("slideOn")}else{$i--}}function h(){$("#loading").fadeOut(500).remove();g()}})};