Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<style type="text/css">
.stepcarousel{
position: relative; /*leave this value alone*/
border: 10px solid black;
overflow: visible; /*leave this value alone*/
width: 270px; /*Width of Carousel Viewer itself*/
height: 200px; /*Height should enough to fit largest content's height*/
}
.stepcarousel .belt{
position: absolute; /*leave this value alone*/
overflow:visible;
left: 0;
top: 0;
}
.stepcarousel .panel{
float: left; /*leave this value alone*/
overflow: hidden; /*clip content that go outside dimensions of holding panel DIV*/
margin: 10px; /*margin around each panel*/
width: 260px; /*Width of each panel holding each content. If removed, widths should be individually defined on each content DIV then. */
}
</style>
</head>
<body>
<input type="button" name="" value="Next" onmouseup="zxcStepCarouselVII.Next('mygallery',1);"/>
<input type="button" name="" value="Back" onmouseup="zxcStepCarouselVII.Next('mygallery',-1);"/>
<input type="button" name="" value="GoTo 0" onmouseup="zxcStepCarouselVII.GoTo('mygallery',0);"/>
<input type="button" name="" value="GoTo 1" onmouseup="zxcStepCarouselVII.GoTo('mygallery',1);"/>
<input type="button" name="" value="GoTo 2" onmouseup="zxcStepCarouselVII.GoTo('mygallery',2);"/>
<input type="button" name="" value="GoTo 3" onmouseup="zxcStepCarouselVII.GoTo('mygallery',3);"/>
<input type="button" name="" value="GoTo 4" onmouseup="zxcStepCarouselVII.GoTo('mygallery',4);"/>
<div id="mygallery" class="stepcarousel">
<div class="belt">
<div class="panel">
<img src="http://www.vicsjavascripts.org/StdImages/0.gif" />
</div>
<div class="panel" >
<img src="http://www.vicsjavascripts.org/StdImages/1.gif" />
</div>
<div class="panel">
<img src="http://www.vicsjavascripts.org/StdImages/2.gif" />
</div>
<div class="panel">
<img src="http://www.vicsjavascripts.org/StdImages/3.gif" />
</div>
<div class="panel">
<img src="http://www.vicsjavascripts.org/StdImages/4.gif" />
</div>
</div>
</div>
<script type="text/javascript">
/*<![CDATA[*/
// Step Carousel VII (15-January-2014)
// by Vic Phillips - http://www.vicsjavascripts.org/
var zxcStepCarouselVII={
Next:function(id,ud){
var o=this['zxc'+id],ud=typeof(ud)=='number'&&ud>0?1:-1;
if (o){
o.ud=ud;
this.rotate(o,o.n+ud);
clearTimeout(o.to);
}
},
GoTo:function(id,n){
var o=this['zxc'+id],ud=typeof(ud)=='number'&&ud>0?1:-1;
if (o){
this.Pause(id);
if (typeof(o.ary[n])=='number'&&n!=o.n&&!(n==0&&o.n==o.lgth)){
n>o.n&&n!=0?1:-1;
this.rotate(o,n);
}
}
},
Auto:function(id,ms){
var oop=this,o=oop['zxc'+id];
o?o.to=setTimeout(function(){ oop.rotate(o,true); },ms||200):null;
},
Pause:function(id){
var o=this['zxc'+id];
if (o){
o.auto=false;
clearTimeout(o.to);
}
},
init:function(o){
var id=o.CarouselID,ms=o.Animate,h=o.AutoHold,srt=o.AutoStart,p=document.getElementById(id),s=p?p.getElementsByTagName('DIV')[0]:null;
if (s){
var sz=0,clds=s.childNodes,c,z0=0
s.style.width='30000px';
p.style.overflow='hidden';
o.ary=[];
for (;z0<clds.length;z0++){
if (clds[z0].nodeType==1){
clds[z0].style.position='absolute';
clds[z0].style.left=sz+'px';
o.ary.push(sz);
sz+=clds[z0].offsetWidth;
}
}
}
s.style.width=sz+'px';
c=s.cloneNode(true);
c.style.left=sz+'px';
c.style.top='0px';
s.appendChild(c);
o.ary.push(sz);
o.id=id;
o.s=[s,'left'];
o.lgth=o.ary.length-1;
o.ms=typeof(ms)=='number'&&ms>20?ms:1000;
o.h=typeof(h)=='number'&&h>20?h:o.ms*4;
o.ud=1;
o.n=0;
this['zxc'+id]=o;
typeof(srt)=='number'&&srt>20?this.Auto(id,srt):null;
},
rotate:function(o,a){
this.Pause(o.id);
o.auto=a===true;
var n=o.auto?o.n+o.ud:a,f=-o.ary[o.n];
if ((n>o.lgth&&o.ud>0)||(n<0&&o.ud<0)){
f=o.ud>0?0:-o.ary[o.lgth];
n=o.ud>0?1:o.lgth-1;
}
this.animate(o,o.s,f,-o.ary[n],new Date(),o.ms);
o.n=n;
},
animate:function(o,a,f,t,srt,mS){
clearTimeout(a[4]);
var oop=this,ms=new Date()-srt,n=(t-f)/mS*ms+f;
if (isFinite(n)){
a[0].style[a[1]]=n+'px';
}
if (ms<mS){
a[4]=setTimeout(function(){ oop.animate(o,a,f,t,srt,mS); },10);
}
else {
a[3]=t;
a[0].style[a[1]]=t+'px';
o.auto?oop.Auto(o.id,o.h):null;
}
}
}
zxcStepCarouselVII.init({
CarouselID:'mygallery', // the unique ID name of the carousel parent DIV. (string)
Animate:1000, //(optional) the step duration in millisec. (number, default = 1000)
AutoHold:1500, //(optional) the auto rotation 'hold' delay in millisec. (number, default = Animate*4)
AutoStart:2000 //(optional) the auto rotation 'start' delay in millisec. (number, default = no auto start)
});
/*]]>*/
</script>
</body>
</html>
Bookmarks