100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > JS简单实现动画弹出层效果【javascript】

JS简单实现动画弹出层效果【javascript】

时间:2020-03-27 16:27:42

相关推荐

JS简单实现动画弹出层效果【javascript】

web前端|js教程

javascript,弹出层

web前端-js教程

JS简单实现动画弹出层效果

最炫表白墙php源码,ubuntu网易云安装,云端tomcat服务器,爬虫chrome扩展,php格式转换pcb格式,百度seo专业 乐云seolzw

动画弹出层.list{position:relative;;background:#eee;border:1px #ccc solid;margin:10px;height:30px;width:100px;cursor :pointer ;}.listShow{position:relative;background:#eff;border:1px #ddd solid;margin:10px;height:30px;width:100px;cursor :pointer ;}.comment{position:absolute;left:0;display:none;position:absolute;border:1px #ccc solid;background:#fee;width:200px;height:200px;overflow:hidden;z-index:100;}

0

1

内容显示111

2

内容显示222

3

内容显示333

var zindex=0;function $id(id){return document.getElementById(id);}var Bind = function(object,fun){var args = Array.prototype.slice.call(arguments).slice(2);return function(){return fun.apply(object,args);}}function addEventHandler(oTarget, sEventType, fnHandler){ if(oTarget.addEventListener){oTarget.addEventListener(sEventType, fnHandler, false);}else if(oTarget.attachEvent){oTarget.attachEvent(on + sEventType, fnHandler);}else{oTarget[on + sEventType] = fnHandler;}}var Shower=function(){this.list=null;ment=null;this.moveLeft=80; this.moveTop=20;this.height=150;this.width=250;this.time=800;this.init=function(lisObj,comObj){this.list=lisObj;ment=comObj;var _this=this;this._fnMove=Bind(this,this.move);(function(){var obj=_this;addEventHandler(obj.list,"click",obj._fnMove);})();};this.move=function(){var _this=this;var w=0; var h=0; var height=0; //弹出div的高var width=0; //弹出div的宽var t=0;var startTime = new Date().getTime();//开始执行的时间if(!ment.style.display||ment.style.display=="none"){ment.style.display="block";ment.style.height=0+"px";ment.style.width=0+"px";_this.list.style.zIndex=++zindex;_this.list.className="listShow";var comment=ment.innerHTML; ment.innerHTML=""; //去掉显示内容var timer=setInterval(function(){var newTime = new Date().getTime();var timestamp = newTime - startTime;ment.style.left=Math.ceil(w)+"px";ment.style.top=Math.ceil(h)+"px";ment.style.height=height+"px";ment.style.width=width+"px";t++;var change=(Math.pow((timestamp/_this.time-1), 3) +1); //根据运行时间得到基础变化量w=_this.moveLeft*change;h=_this.moveTop*change;height=_this.height*change;width=_this.width*change;$id("show").innerHTML=w;if(w>_this.moveLeft){clearInterval(timer);ment.style.left=_this.moveLeft+"px";ment.style.top=_this.moveTop+"px"; ment.style.height=_this.height+"px";ment.style.width=_this.width+"px";ment.innerHTML=comment; //回复显示内容}},1,ment);}else{_this.hidden();}}this.hidden=function(){var _this=this;var flag=1;var hiddenTimer=setInterval(function(){if(flag==1){ment.style.height=parseInt(ment.style.height)-10+"px";}else{ ment.style.width=parseInt(ment.style.width)-15+"px";ment.style.left=parseInt(ment.style.left)+5+"px";}if(flag==1 && parseInt(ment.style.height)<10){flag=-flag;}if(parseInt(ment.style.width)<20){clearInterval(hiddenTimer);ment.style.left="0px";ment.style.top="0px";ment.style.height="0px";ment.style.width="0px";ment.style.display="none";if(_this.list.style.zIndex==zindex){zindex--;};_this.list.style.zIndex=0;_this.list.className="list";}},1)}}window.onload=function(){//建立各个菜单对象var shower1=new Shower();shower1.init($id("list1"),$id("comment1"));var shower2=new Shower();shower2.init($id("list2"),$id("comment2"));var shower3=new Shower();shower3.init($id("list3"),$id("comment3"));}以上所述就是本文的全部内容了,希望大家能够喜欢。

java 会员管理系统 俱乐部 源码,更改左上角vscode图标,ubuntu突然变慢,tomcat默认同步,爬虫实战小说,php实现负载均衡,海南专业seo大概多少钱lzw

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。