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">
/*<![CDATA[*/
.someclass {
position:relative;top:0px;width:200px;height:160px;border:solid red 1px;text-Align:center;
}
/*]]>*/
</style>
</head>
<body>
<input type="button" name="" value="Auto" onmouseup="zxcScroller.Auto('tst');" />
<input type="button" name="" value="Pause" onmouseup="zxcScroller.Pause('tst');" />
<input type="button" name="" value="Next" onmouseup="zxcScroller.Next('tst',2);" />
<input type="button" name="" value="Back" onmouseup="zxcScroller.Next('tst',-2);" />
<input type="button" name="" value="GoTo 0" onmouseup="zxcScroller.GoTo('tst',0);" />
<input type="button" name="" value="GoTo 1" onmouseup="zxcScroller.GoTo('tst',1);" />
<input type="button" name="" value="GoTo 2" onmouseup="zxcScroller.GoTo('tst',2);" />
<input type="button" name="" value="GoTo 3" onmouseup="zxcScroller.GoTo('tst',3);" />
<div id="tst" class="someclass" ></div>
<div id="tst2" class="someclass" onmouseover="zxcScroller.Pause('tst2');" onmouseout="zxcScroller.Auto('tst2'); "></div>
<script type="text/javascript">
/*<![CDATA[*/
// Scroller (17-October-2013)
// by Vic Phillips - http://www.vicsjavascripts.org.uk/
var zxcScroller={
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,ms){
var o=this['zxc'+id];
if (o){
clearTimeout(o.to);
o.auto=false;
}
},
GoTo:function(id,n){
var o=this['zxc'+id];
if (o){
this.Pause(id);
if(o.ary[n]&&n!=o.c){
o.ud=n>o.c?1:-1;
this.rotate(o,n);
}
}
},
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.c+ud);
}
},
init:function(o){
var id=o.ScrollerID,ary=o.ContentArray,ms=o.Animate,m=o.Mode,hold=o.AutoHold,srt=o.AutoStart,add=o.AddEvents,p=document.getElementById(id);
if (p&&ary instanceof Array&&!this['zxc'+id]){
var w=p.offsetWidth,h=p.offsetHeight,m=typeof(m)=='string'&&m.charAt(0)=='H'?['left',w]:['top',h],d=document.createElement('DIV'),s,t,z0=0;
p.style.overflow='hidden';
o.id=id;
o.ary=ary;
o.sz=-m[1];
d.style.position='absolute';
d.style.left=d.style.top='0px';
d.style.height=h+'px';
d.style.width=w+'px';
s=d.cloneNode(false);
p.appendChild(s);
d.style.overflow='hidden';
o.ds=[d.cloneNode(false),d.cloneNode(false)];
s.appendChild(o.ds[0]);
s.appendChild(o.ds[1]);
o.s=[s,m[0]];
o.ms=typeof(ms)=='number'&&ms>20?ms:1000;
o.hold=typeof(hold)=='number'&&hold>20?hold:o.ms*4;
o.lgth=ary.length-1;
o.ud=1;
o.c=o.ud>0?1:o.lgth;
o.ds[0].innerHTML=ary[0];
o.ds[1].innerHTML=ary[o.ud>0?1:o.lgth];
o.ds[1].style[m[0]]=o.sz*(o.ud>0?-1:1)+'px';
if (add instanceof Array){
for (;z0<add.length;z0++){
if (add[z0]){
d=document.getElementById(add[z0][0]);
if (d&&this[add[z0][2]]){
t=add[z0][1];
this.addevt(d,t=='click'||t=='mouseover'||t=='mouseout'||t=='mousedown'?t:'mouseup',add[z0][2],o.id,add[z0][3]);
}
}
}
}
this['zxc'+id]=o;
typeof(srt)=='number'&&srt>=0?this.Auto(id,srt):null;
}
},
rotate:function(o,a){
this.Pause(o.id);
var c=o.c;
o.auto=a===true;
c=o.auto?c+o.ud:a;
c=o.ary[c]?c:o.ud>0?0:o.lgth;
o.ds[1].style[o.s[1]]=o.sz*(o.ud>0?-1:1)+'px';
o.c=c;
o.ds[1].innerHTML=o.ary[o.c];
this.animate(o,o.s,0,o.sz*(o.ud>0?1:-1),new Date(),o.ms);
},
animate:function(o,a,f,t,srt,mS,c){
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,c); },10);
}
else {
a[0].style[a[1]]='0px';
o.ds[0].innerHTML=o.ds[1].innerHTML;
o.auto?oop.Auto(o.id,o.hold):null;
}
},
addevt:function(o,t,f,p,p1){
var oop=this;
o.addEventListener?o.addEventListener(t,function(e){ return oop[f](p,p1);},false):o.attachEvent?o.attachEvent('on'+t,function(e){ return oop[f](p,p1); }):null;
}
}
/*]]>*/
</script>
<script type="text/javascript">
/*<![CDATA[*/
zxcScroller.init({
ScrollerID:'tst', // the unique ID name of the parent DIV. (string)
ContentArray:[ // the content definition array. (array)
'<img draggable="false" src="http://gve.com.pg/images/layout/best-quality-gold.png" alt="" />',
'<a href="#">Gold Nuggets</a><br><br> Gold nuggets are of richer in quality with deeper in orange yellow colour and pure eminent concentration of guaranteed natural fine gold.',
'<a href="#">Gold Ingots</a><br><br> Yellow solid gold bars of fine quality are famous for their intrinsic purity and longevity and are available in customized weight proportions.',
'<a href="#">New office</a><br><br> We also proudly wish to announce that our next branch office is to be opened shortly in the central capital city of Colombo, Sri Lanka.'
],
Mode:'Vertical', //(optional) the display mode, 'Vertical' or 'Horizontal'. (string, default = 'Vertical')
Animate:1000, //(optional) the animation duration in millisec. (number, default = 1000)
AutoHold:3000, //(optional) the auto rotate 'hold' delay in millisec. (number, default = Animate*4)
AutoStart:2000, //(optional) the auto rotate start delay in millisec. (number, default = 100)
AddEvents:[ //(optional) add event calls to control the script. (array, default = inline event calls)
// field 0 = the element unique ID name.
// field 1 = the event type.
// field 2 = the script function name.
// field 3 = (optional) the value to pass to the function.
['tst','mouseover','Pause'],
['tst','mouseout','Auto',1000]
]
});
zxcScroller.init({
ScrollerID:'tst2',
ContentArray:[
'<img draggable="false" src="http://gve.com.pg/images/layout/best-quality-gold.png" alt="" />',
'<a href="#">Gold Nuggets</a><br><br> Gold nuggets are of richer in quality with deeper in orange yellow colour and pure eminent concentration of guaranteed natural fine gold.',
'<a href="#">Gold Ingots</a><br><br> Yellow solid gold bars of fine quality are famous for their intrinsic purity and longevity and are available in customized weight proportions.',
'<a href="#">New office</a><br><br> We also proudly wish to announce that our next branch office is to be opened shortly in the central capital city of Colombo, Sri Lanka.'
],
AutoStart:0,
Mode:'Horizontal'
});
/*]]>*/
</script>
</body>
</html>
Bookmarks