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[*/
#m1 {
position:relative;left:100px;top:100px;width:600px;height:20px;border:solid red 1px;background-Color:#FFFFCC;
}
#m1 DIV {
position:absolute;left:600px;top:0px;width:700px;height:20px;
}
/*]]>*/
</style></head>
<body>
<div id="m1" onmouseover="zxcMarquee.Pause('m1')" onmouseout="zxcMarquee.Scroll('m1')">
<div onmouseover="zxcMarquee.Pause('m1')" >Some Text</div>
</div>
<script type="text/javascript">
/*<![CDATA[*/
// Simple Marquee. (24-September-2013)
// by: Vic Phillips - http://www.vicsjavascripts.org.uk/
var zxcMarquee={
Scroll:function(id,ms){
var o=this['zxc'+id],oop=this;
o?o.to=setTimeout(function(){ oop.scroll(o); },ms||500):null;
},
Pause:function(id,ms){
var o=this['zxc'+id];
o?clearTimeout(o.to):null;
},
init:function(o){
var id=o.ID,ms=o.ScrollDuration,srt=o.AutoStart,r=o.Repeat,m=document.getElementById(id),s=m?m.getElementsByTagName('DIV')[0]:null;
if (s){
m.style.overflow='hidden';
o.a=[s,'left',s.offsetLeft,-s.offsetWidth,s.offsetLeft];
o.a[5]=o.a[2]-o.a[3];
o.ms=(typeof(ms)=='number'&&ms>0?ms:10)*1000;
o.r=typeof(r)=='number'&&r>=0?r*1000+5:false;
o.id=id;
this['zxc'+id]=o;
typeof(srt)=='number'&&srt>0?this.Scroll(id,srt*1000):null;
}
},
scroll:function(o,a){
clearTimeout(o.to);
this.animate(o,o.a,o.a[4],o.a[3],new Date(),o.ms*Math.abs((o.a[3]-o.a[4])/o.a[5])+10);
},
animate:function(o,a,f,t,srt,mS){
clearTimeout(o.to);
var oop=this,ms=new Date()-srt,n=(t-f)/mS*ms+f;
if (isFinite(n)){
a[4]=n;
a[0].style[a[1]]=a[4]+'px';
}
if (ms<mS){
o.to=setTimeout(function(){ oop.animate(o,a,f,t,srt,mS); },10);
}
else {
a[4]=a[2];
a[0].style[a[1]]=t+'px';
o.r?oop.Scroll(o.id,o.r):null;
}
}
}
zxcMarquee.init({
ID:'m1', // the unique ID name of the marquee DIV. (string)
ScrollDuration:10, //(optional) the scroll duration in secconds. (number, default = 10)
AutoStart:20, //(optional) the auto scroll start delay in seconds. (number, default = no auto start)
Repeat:false //(optional) repeat scroll after n seconds. (number, default = false = no repeat)
});
/*]]>*/
</script>
</body>
</html>
Bookmarks