or even
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>
<script type="text/javascript">
/*<![CDATA[*/
// Window Scroll (29-December-2008) DRAFT
// by Vic Phillips http://www.vicsjavascripts.org.uk
// **** Executing the Effect(Script)
//
// The effect is executed by an event call to function 'zxcScroll(srt,fin,ms,curve);'
// where:
// parameter 0 = the start position of the effect. (digits)
// parameter 1 = the finish position of the effect. (digits)
// parameter 2 = (optional) the type of progression, 'sin', 'cos' or 'liner'. (string)
// 'sin' progression starts fast and ends slow.
// 'cos' progression starts slow and ends fast.
// parameter 3 = (optional) period of time between the start and finish of the effect in milliseconds. (digits or defaults to 1000 milliSeconds)
//
// **** Functional Code - NO NEED to Change
function zxcScroll(srt,fin,curve,ms){
var oop=window.scrolloop;
if (oop){
clearTimeout(oop.to);
oop.update([srt,fin],ms);
}
else window.scrolloop=new zxcBAnimatorOOP(srt,fin,curve,ms);
}
function zxcBAnimatorOOP(srt,fin,curve,ms){
this.to=null;
this.update([srt,fin],curve,ms);
}
zxcBAnimatorOOP.prototype.update=function(srtfin,curve,ms){
this.curve=(typeof(curve)=='string')?curve.charAt(0).toLowerCase():(this.curve)?this.curve:'x';
this.ms=ms||1000;
this.x=zxcScrollX();
this.sf=[srtfin[0],srtfin[1]];
this.inc=Math.PI/(2*this.ms);
this.srttime=new Date().getTime();
this.cng();
}
zxcBAnimatorOOP.prototype.cng=function(){
var ms=new Date().getTime()-this.srttime;
window.scroll(this.x,(this.curve=='s')?Math.floor((this.sf[1]-this.sf[0])*Math.sin(this.inc*ms)+this.sf[0]):(this.curve=='c')?(this.sf[1])-Math.floor((this.sf[1]-this.sf[0])*Math.cos(this.inc*ms)):(this.sf[1]-this.sf[0])/this.ms*ms+this.sf[0]);
if (ms<this.ms) this.to=setTimeout(function(oop){return function(){oop.cng();}}(this),10);
else {
}
}
function zxcScrollX(){
if (window.innerHeight) return window.pageXOffset;
else if (document.documentElement.clientHeight) return document.documentElement.scrollLeft;
return document.body.scrollLeft;
}
/*]]>*/
</script>
<script type="text/javascript">
/*<![CDATA[*/
function Enlarge(img,ms){
zxcScroll(zxcWWHS()[3],zxcPos(img)[1]-(zxcWWHS()[1]/2-img.offsetHeight/2),'sin',ms);
}
function zxcWWHS(){
if (window.innerHeight) return [window.innerWidth-10,window.innerHeight-10,window.pageXOffset,window.pageYOffset];
else if (document.documentElement.clientHeight) return [document.documentElement.clientWidth-10,document.documentElement.clientHeight-10,document.documentElement.scrollLeft,document.documentElement.scrollTop];
return [document.body.clientWidth,document.body.clientHeight,document.body.scrollLeft,document.body.scrollTop];
}
function zxcPos(obj){
var rtn=[obj.offsetLeft,obj.offsetTop];
while(obj.offsetParent!=null){
var objp=obj.offsetParent;
rtn[0]+=objp.offsetLeft-objp.scrollLeft;
rtn[1]+=objp.offsetTop-objp.scrollTop;
obj=objp;
}
return rtn;
}
/*]]>*/
</script></head>
<body>
<div style="height:400px;" ></div>
<img src="http://www.vicsjavascripts.org.uk/StdImages/One.gif" onclick="Enlarge(this,1000);" />
<div style="height:600px;" ></div>
</body>
</html>
Bookmarks