600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > JS实现文字掉落效果办法【javascript】

JS实现文字掉落效果办法【javascript】

时间:2018-09-21 12:58:01

相关推荐

JS实现文字掉落效果办法【javascript】

web前端|js教程

JS,文字掉落效果

web前端-js教程

本文实例讲述了JS实现文字掉落效果的方法。分享给大家供大家参考。具体实现方法如下:

卡五星 源码,vscode加超链接,ubuntu开始wifi,tomcat非法连接错误,爬虫证件,php记账源码,怒江seo培训哪家好,理财网站系统源码,html 联系我们模板lzw

.canvas{width:500px;height:500px;position:relative;}

/**坠落效果*/function Falling(){ this.dict=["abcd","2222","sign","next","container","content","last","break","less","than","that","absolute","relative","my","index","html","java","c#","web","javascript","php","include","shit","bull","big","smart","call","apply","callee","caller","function"]; this.canvas=$("#canvas"); this.step=15; this.freq=10; this.height=500; this.width=500; this.si=null;}Falling.prototype={ fallingAction:function(dom){ var self=this; var freqs=[10,15,20];//每次下落的距离 var disS=[];//记录所有dom的当前距离 var disPerFreqS=[];//每个dom的 var targetDis=500; var domCssTopS=[];//所有dom的top属性 var successDom=[];//记录哪些dom已经结束运动 var successCount=0;//有多少个dom已经结束 var total=dom.length; var freqMarkLength=freqs.length; for(var i=0,j=dom.length;i=total){ clearInterval(self.si); } for(var i=0,j=dom.length;i= targetDis){dom[i].css("top", targetDis+domCssTopS[i]);successDom[i]="ok";successCount++;; }else{dom[i].css("top", disS[i]+domCssTopS[i]); } } },self.freq); }, init:function(){ var self=this; self.canvas.html(\); var dom=[]; var l=0; var t=0; var tempDom=$("

").appendTo($("body")); for(var i=0,j=self.dict.length;i<j;i++){ dom[i]=$(""+self.dict[i]+"").appendTo(tempDom); var domWidth=dom[i].width(); var domHeight=dom[i].height(); if(t<self.height){ if(l<self.width){if(domWidth+l<=self.width){dom[i].css({"top":t,"left":l});self.canvas.append(dom[i]);l += dom[i].width();}else{if(domHeight+t<=self.height){ t=t+domHeight; dom[i].css({"top":t,"left":0}); self.canvas.append(dom[i]); l = dom[i].width();}else{ break;//到极限了}} }else{if(domHeight+t<=self.height){ t=t+domHeight; l=0; dom[i].css({"top":t,"left":l}); self.canvas.append(dom[i]);}else{ break;//到极限了} } }//else极限 } /* for(var i=0,l=self.dict.length;i<l;i++){ self.fallingAction(dom[i]); } */ self.fallingAction(dom); }}var falling=new Falling();falling.init();

jfinal 类继承源码,vscode 格式化规则,ubuntu 中ln,tomcat参数怎么调,爬虫工具py,php随机生成6位数,四川seo推广费用多少,社区团购网站源代码lzw

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