这次给大家带来js推拉门效果的实现,js推拉门效果实现的注意事项有哪些,下面就是实战案例,一起来看一下。
// javascript document
function startmove(obj,json,endfn){
clearinterval(obj.timer);
obj.timer = setinterval(function(){
var bbtn = true;
for(var attr in json){
var icur = 0;
if(attr == 'opacity'){
if(math.round(parsefloat(getstyle(obj,attr))*100)==0){
icur = math.round(parsefloat(getstyle(obj,attr))*100);
}
else{
icur = math.round(parsefloat(getstyle(obj,attr))*100) || 100;
}
}
else{
icur = parseint(getstyle(obj,attr)) || 0;
}
var ispeed = (json[attr] - icur)/8;
ispeed = ispeed >0 ? math.ceil(ispeed) : math.floor(ispeed);
if(icur!=json[attr]){
bbtn = false;
}
if(attr == 'opacity'){
obj.style.filter = 'alpha(opacity=' +(icur + ispeed)+ ')';
obj.style.opacity = (icur + ispeed)/100;
}
else{
obj.style[attr] = icur + ispeed + 'px';
}
}
if(bbtn){
clearinterval(obj.timer);
if(endfn){
endfn.call(obj);
}
}
},30);
}
function getstyle(obj,attr){
if(obj.currentstyle){
return obj.currentstyle[attr];
}
else{
return getcomputedstyle(obj,false)[attr];
}
}
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
js使用正则进行密码强度验证
js实现标签点击切换代码(附代码)
以上就是js推拉门效果的实现的详细内容。