diff --git a/lib/Snowflake.js b/lib/Snowflake.js index b006fa6..27ee5c8 100644 --- a/lib/Snowflake.js +++ b/lib/Snowflake.js @@ -56,7 +56,7 @@ function () { if (ctx) { ctx.beginPath(); ctx.arc(_this.params.x, _this.params.y, _this.params.radius, 0, 2 * Math.PI); - ctx.fillStyle = _this.params.color; + ctx.fillStyle = _this.fullConfig.color; ctx.closePath(); ctx.fill(); } @@ -98,12 +98,10 @@ function () { this.config = config; // Setting initial parameters var _this$fullConfig = this.fullConfig, - color = _this$fullConfig.color, radius = _this$fullConfig.radius, _wind = _this$fullConfig.wind, _speed = _this$fullConfig.speed; this.params = { - color: color, x: (0, _utils.random)(0, _canvas.offsetWidth), y: (0, _utils.random)(-_canvas.offsetHeight, 0), radius: _utils.random.apply(void 0, _toConsumableArray(radius)), @@ -126,4 +124,5 @@ function () { }(); var _default = Snowflake; -exports["default"] = _default; \ No newline at end of file +exports["default"] = _default; +//# sourceMappingURL=Snowflake.js.map \ No newline at end of file diff --git a/src/Snowfall.tsx b/src/Snowfall.tsx index 37a5fc8..38fc0ac 100644 --- a/src/Snowfall.tsx +++ b/src/Snowfall.tsx @@ -57,7 +57,6 @@ const Snowfall = ({ color = '#dee4fd', snowflakeCount = 150, style }: SnowfallPr }, [render]) useEffect(() => { - console.log('useEffect') loop() return () => cancelAnimationFrame(animationFrame.current) }, [loop]) diff --git a/src/Snowflake.ts b/src/Snowflake.ts index 6f7c5dd..115bc9d 100644 --- a/src/Snowflake.ts +++ b/src/Snowflake.ts @@ -19,7 +19,6 @@ const defaultConfig: SnowflakeProps = { } interface SnowflakeParams { - color: string x: number y: number radius: number @@ -40,9 +39,9 @@ class Snowflake { this.config = config // Setting initial parameters - const { color, radius, wind, speed } = this.fullConfig + const { radius, wind, speed } = this.fullConfig + this.params = { - color, x: random(0, canvas.offsetWidth), y: random(-canvas.offsetHeight, 0), radius: random(...radius), @@ -67,7 +66,7 @@ class Snowflake { if (ctx) { ctx.beginPath() ctx.arc(this.params.x, this.params.y, this.params.radius, 0, 2 * Math.PI) - ctx.fillStyle = this.params.color + ctx.fillStyle = this.fullConfig.color ctx.closePath() ctx.fill() }