A
Annihilus
Я хотел бы узнать как в данном скрипте, повысить скорость возврата (картинки) на исходную позицию
----------------------------------------------------
<script type="text/javascript">
<!--
function initObj(){ // create objects
my_object1=new create("div1")
my_object2=new create("div2")
maxWidth=300
minWidth=115
}
function create(id){ //define properties, pass id
this.id=id
this.width=document.getElementById(this.id).width
this.pos=parseInt(document.getElementById(this.id).style.left)
this.start_pos=this.pos
this.timer=null
this.running=0
this.chk_status=function(num,d){
this.dir=d
if(this.dir=="zOut"){this.running=0}
if(this.dir=="zIn"&&this.running==1){return}
this.running=1
this.step=5//+Math.floor(Math.random()*9)
window["my_object"+num].animate('my_object'+num)
}
this.animate=function(myobject){
if(this.dir=="zIn"){
document.getElementById(this.id).style.zIndex=1
this.width+=this.step
this.pos-= this.step/2
}
else{
document.getElementById(this.id).style.zIndex=""
this.width-=this.step/4
this.pos+= (this.step/2)/4
}
this.timer=setTimeout(myobject+".animate('"+myobject+"')",0)
if(this.dir=="zIn"&&this.width>maxWidth-this.step){
this.width=maxWidth
this.running=0
clearTimeout(this.timer)
}
if(this.dir=="zOut"&&this.width<=minWidth+this.step){
this.width=minWidth
this.pos=this.start_pos
this.running=0
clearTimeout(this.timer)
}
document.getElementById(this.id).style.width=this.width
document.getElementById(this.id).style.left=this.pos
}
}
</script>
----------------------------------------------------
<script type="text/javascript">
<!--
function initObj(){ // create objects
my_object1=new create("div1")
my_object2=new create("div2")
maxWidth=300
minWidth=115
}
function create(id){ //define properties, pass id
this.id=id
this.width=document.getElementById(this.id).width
this.pos=parseInt(document.getElementById(this.id).style.left)
this.start_pos=this.pos
this.timer=null
this.running=0
this.chk_status=function(num,d){
this.dir=d
if(this.dir=="zOut"){this.running=0}
if(this.dir=="zIn"&&this.running==1){return}
this.running=1
this.step=5//+Math.floor(Math.random()*9)
window["my_object"+num].animate('my_object'+num)
}
this.animate=function(myobject){
if(this.dir=="zIn"){
document.getElementById(this.id).style.zIndex=1
this.width+=this.step
this.pos-= this.step/2
}
else{
document.getElementById(this.id).style.zIndex=""
this.width-=this.step/4
this.pos+= (this.step/2)/4
}
this.timer=setTimeout(myobject+".animate('"+myobject+"')",0)
if(this.dir=="zIn"&&this.width>maxWidth-this.step){
this.width=maxWidth
this.running=0
clearTimeout(this.timer)
}
if(this.dir=="zOut"&&this.width<=minWidth+this.step){
this.width=minWidth
this.pos=this.start_pos
this.running=0
clearTimeout(this.timer)
}
document.getElementById(this.id).style.width=this.width
document.getElementById(this.id).style.left=this.pos
}
}
</script>