function Animation(list) {
this.box = document.getElementById(list.id);
this.size = list.size;
this.url = list.url; this.init() // Animation.prototype中的init(),初始化一些值(非私有)
this.DOMready(); // 调用Animation.prototype中的 DOMready(),每一个new Animation()都会执行这里面的语句
} Animation.prototype = {
// 1.init:初始化一些非私有值
init:function(){
this.width = box.clientWidth;
this.height = box.clientHeight;
}, // 2.DOMready:用来生成div的,用到定时器,循环设置
DOMready: function(){
var box = this.box;
var size = this.size;
// 下面保存了this(Animation)到self之中,因为等会要调用Animation.DOMmove(cirDiv)
var self = this; var timer = setInterval(function(){
var top = ;
var xPosition = Math.random()*(self.width - self.size);
var cirDiv = document.createElement("div");
cirDiv.style.cssText = "background:"+LYX_Colors_getRandomColor()+";"+"left:"+xPosition+"px;"+ "width:25px;height:25px;border-radius: 50%;position: absolute;";
box.appendChild(cirDiv); // 调用Animation.DOMmove(cirDiv),给每个div设置定时器,用来调整top值
self.DOMmove(cirDiv)
}, )
}, // 3.调整top值函数
DOMmove: function(cirDiv) {
var top = ;
var self = this;
var cirDiv = cirDiv;
var timer_2 = setInterval(function() {
top++;
cirDiv.style.top = top+"px";
if (top > self.height - self.size) {
box.removeChild(cirDiv);
clearInterval(timer_2);
}
},)
}
} // 新建s调用方法
var s = new Animation({
id: "box",
size: ""
});

最新文章

  1. static、const和static const
  2. 超强语感训练文章(Provided by Rocky teacher Prince)
  3. vs2010调试程序出现“Cannot find or open the PDB file”
  4. [转].NET下读取PDF文本
  5. magento搬家步骤和可能遇到的问题
  6. 引用类型之Function类型
  7. Maven POM.xml (转)
  8. Android面向HTTP协议发送post请求
  9. 【HDOJ】1510 White Rectangles
  10. win7+ ubuntu 双系统
  11. Spring Cloud 微服务架构全链路实践
  12. JVM虚拟机深入理解+GC回收+类加载
  13. 烧写树莓派系统,SSH配置,无屏登录流程
  14. Linux_CentOS-服务器搭建 <五> 补充
  15. 20165225《Java程序设计》第九周学习总结
  16. Porsche Piwis Tester 2 Online Coding Guide
  17. Java中,&&与&,||与|的区别
  18. mysql字符串类型数据
  19. 14 ConfigParse模块
  20. shiro授权-记调试过程

热门文章

  1. bug提交模板
  2. css初始化样例代码
  3. Zookeeper 分布式环境搭建
  4. Windows CMD命令大全
  5. hiveserver2
  6. 【POJ】2296 Map Labeler
  7. NOI模拟赛Day3
  8. 彩色照片转换为黑白照片(Color image converted to black and white picture)
  9. C语言(3)
  10. tomcat、Linux服务器