|
|
|
ขอถามเรื่องการหน่วงเวลาให้ smooth ในการ hide และ show element หน่อยครับ |
|
|
|
|
|
|
|
ใช้ jQuery ครับ
$('#test').fadeIn(5000);
|
|
|
|
|
Date :
2010-02-08 22:40:54 |
By :
danya |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
กดลิงค์เพื่อดูตัวอย่าง :> http://imwriter.keedkean.com/show.php?id=6
Code (PHP)
<script type='text/javascript'>
var slide={
tmo:null,
opa:100,
duration:140,
frame:8,
process:false,
active:function(a){
if(this.process)return;
if(a=='show') this.show();
else this.hide();
},
show:function(){
if(this.opa<100){
this.process=true;
this.opa+=100/this.frame;
this.setOpacity(this.opa,'imgs');
var _this =this;
this.tmo=setTimeout(function(){_this.show()},this.duration);
}else{
this.setOpacity(100,'imgs');
clearTimeout(this.tmo);
this.process=false;
}
},
hide:function(){
if(this.opa>0){
this.process=true;
this.opa-=100/this.frame;
this.setOpacity(this.opa,'imgs');
var _this =this;
this.tmo=setTimeout(function(){_this.hide()},this.duration);
}else{
clearTimeout(this.tmo);
this.setOpacity(0,'imgs');
this.process=false;
}
},
setOpacity:function(setOpacity, objectId){
var object = document.getElementById(objectId).style;
object.opacity = (setOpacity / 100);
object.MozOpacity = (setOpacity / 100);
object.KhtmlOpacity = (setOpacity / 100);
object.filter = "alpha(opacity=" + setOpacity + ")";
}
}
</script>
<img src='http://www.keedkean.com/images/upload/2/220100208104545.jpg' id='imgs'><br>
<input type='button' value='click to show' onclick="slide.active('show')"><input type='button' value='click to hide' onclick="slide.active('hide')">
|
|
|
|
|
Date :
2010-02-08 23:55:27 |
By :
xbeginner01 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากๆครับ
|
|
|
|
|
Date :
2010-02-10 16:15:23 |
By :
wombatman |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|