md
This commit is contained in:
parent
0cc14dcf8a
commit
45a8c50e93
|
@ -32,9 +32,8 @@
|
||||||
## 反馈
|
## 反馈
|
||||||
我们目前没有写反馈的接口和功能 你可以加群 点击链接加入群聊【铁锈助手】:https://qm.qq.com/q/dUfOK04pj2 在此反馈
|
我们目前没有写反馈的接口和功能 你可以加群 点击链接加入群聊【铁锈助手】:https://qm.qq.com/q/dUfOK04pj2 在此反馈
|
||||||
|
|
||||||
## 特别鸣谢 (参与项目开发)
|
## 特别鸣谢 (参与项目开发)<!DOCTYPE html>
|
||||||
<!DOCTYPE html>
|
<html lang="zh-CN">
|
||||||
<html>
|
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
|
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
|
||||||
<style>
|
<style>
|
||||||
|
@ -42,7 +41,6 @@
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#box {
|
#box {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
|
@ -52,13 +50,10 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="box">
|
<div id="box">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function () {
|
(function () {
|
||||||
var screenWidth = screen.availWidth; // 获取屏幕宽度
|
var screenWidth = screen.availWidth; // 获取屏幕宽度
|
||||||
|
@ -73,7 +68,6 @@
|
||||||
this.init(); // 初始化
|
this.init(); // 初始化
|
||||||
this.start(); // 开始下雪
|
this.start(); // 开始下雪
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取相关随机数据的方法
|
// 获取相关随机数据的方法
|
||||||
Snow.prototype.getRandomThings = function (type) {
|
Snow.prototype.getRandomThings = function (type) {
|
||||||
var res;
|
var res;
|
||||||
|
@ -91,7 +85,6 @@
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
Snow.prototype.init = function () {
|
Snow.prototype.init = function () {
|
||||||
this.box.style.width = screenWidth + 'px'; // 设置容器宽度为屏幕宽度
|
this.box.style.width = screenWidth + 'px'; // 设置容器宽度为屏幕宽度
|
||||||
this.box.style.height = screenHeight + 'px'; // 设置容器高度为屏幕高度
|
this.box.style.height = screenHeight + 'px'; // 设置容器高度为屏幕高度
|
||||||
|
@ -111,7 +104,6 @@
|
||||||
}
|
}
|
||||||
box.appendChild(fragment); // 将文档片段添加到容器中
|
box.appendChild(fragment); // 将文档片段添加到容器中
|
||||||
}
|
}
|
||||||
|
|
||||||
Snow.prototype.start = function () {
|
Snow.prototype.start = function () {
|
||||||
var that = this;
|
var that = this;
|
||||||
var num = 0;
|
var num = 0;
|
||||||
|
@ -127,7 +119,6 @@
|
||||||
})(snow, num)
|
})(snow, num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 针对每个雪花的定时处理
|
// 针对每个雪花的定时处理
|
||||||
Snow.prototype.doStart = function (snow) {
|
Snow.prototype.doStart = function (snow) {
|
||||||
var that = this;
|
var that = this;
|
||||||
|
@ -143,7 +134,6 @@
|
||||||
// 重新回到天上开始往下
|
// 重新回到天上开始往下
|
||||||
increTop = that.getRandomThings('incre');
|
increTop = that.getRandomThings('incre');
|
||||||
increLeft = that.getRandomThings('increLeft');
|
increLeft = that.getRandomThings('increLeft');
|
||||||
|
|
||||||
// 重新随机属性
|
// 重新随机属性
|
||||||
var left = that.getRandomThings('left');
|
var left = that.getRandomThings('left');
|
||||||
var top = that.getRandomThings('top');
|
var top = that.getRandomThings('top');
|
||||||
|
@ -154,30 +144,23 @@
|
||||||
y = top;
|
y = top;
|
||||||
x = left;
|
x = left;
|
||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加上系数,当随机数大于0.5时速度加快,小于0.5时速度减慢,形成飘动效果
|
// 加上系数,当随机数大于0.5时速度加快,小于0.5时速度减慢,形成飘动效果
|
||||||
x += Math.random() > 0.5 ? increLeft * 1.1 : increLeft * 0.9;
|
x += Math.random() > 0.5 ? increLeft * 1.1 : increLeft * 0.9;
|
||||||
y += Math.random() > 0.5 ? increTop * 1.1 : increTop * 0.9;
|
y += Math.random() > 0.5 ? increTop * 1.1 : increTop * 0.9;
|
||||||
|
|
||||||
// 设置left和top值使雪花动起来
|
// 设置left和top值使雪花动起来
|
||||||
s.style.left = x + 'px';
|
s.style.left = x + 'px';
|
||||||
s.style.top = y + 'px';
|
s.style.top = y + 'px';
|
||||||
}, speed); // 每隔speed毫秒执行一次定时器中的代码
|
}, speed); // 每隔speed毫秒执行一次定时器中的代码
|
||||||
})(snow)
|
})(snow)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取元素的样式值
|
// 获取元素的样式值
|
||||||
function getStyle(obj, prop) {
|
function getStyle(obj, prop) {
|
||||||
var prevComputedStyle = document.defaultView ? document.defaultView.getComputedStyle(obj, null) : obj.currentStyle;
|
var prevComputedStyle = document.defaultView ? document.defaultView.getComputedStyle(obj, null) : obj.currentStyle;
|
||||||
return prevComputedStyle[prop];
|
return prevComputedStyle[prop];
|
||||||
}
|
}
|
||||||
|
|
||||||
new Snow(300, 30); // 创建一个Snow对象,传入雪花数量和每批下落的雪花数量
|
new Snow(300, 30); // 创建一个Snow对象,传入雪花数量和每批下落的雪花数量
|
||||||
})()
|
})()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user