Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglin2 committed Dec 27, 2020
1 parent 6093ed4 commit e8438b6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Snow {
this.x = 0
// 重置位置
this.y = 0
// z轴位置
this.z = 0
// 水平速度
this.sx = 0
// 是否左右摇摆
Expand Down Expand Up @@ -64,6 +66,7 @@ class Snow {
}
this.sy = isQuick ? Math.random() * this.quickMaxSpeed + this.quickMinSpeed : Math.random() * this.maxSpeed + this.minSpeed
this.sx = this.dir === 'r' ? this.sy : -this.sy
this.z = isQuick ? Math.random() * 300 + 200 : 0
this.swingStep = 0.01 * Math.random()
this.swingRadian = Math.random() * (1.1 - 0.9) + 0.9
}
Expand All @@ -77,7 +80,7 @@ class Snow {
display: block;
width: ${this.isRain ? 1 : this.width}px;
height: ${this.width}px;
opacity: ${this.isRain ? 1 : this.opacity};
opacity: ${this.opacity};
background-image: radial-gradient(#fff 0%, rgba(255, 255, 255, 0) 60%);
border-radius: 50%;
z-index: 9999999999999;
Expand Down Expand Up @@ -118,7 +121,7 @@ class Snow {
this.init(true)
this.setStyle()
}
this.el.style.transform = `translate(${this.x}px, ${this.y}px) ${this.getRotate(this.sy, this.sx)}`
this.el.style.transform = `translate3d(${this.x}px, ${this.y}px, ${this.z}px) ${this.getRotate(this.sy, this.sx)}`
}

getRotate(sy, sx) {
Expand Down

0 comments on commit e8438b6

Please sign in to comment.