react-native-snow-backgroud 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { useEffect, useRef } from "react";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { Dimensions, View, StyleSheet } from "react-native";
|
|
5
5
|
import { Canvas, Circle } from "@shopify/react-native-skia";
|
|
6
6
|
import { SnowEngine } from "./SnowEngine.js";
|
|
@@ -14,6 +14,7 @@ export function SnowView({
|
|
|
14
14
|
height
|
|
15
15
|
} = Dimensions.get("window");
|
|
16
16
|
const engineRef = useRef(null);
|
|
17
|
+
const [, forceRender] = useState(0);
|
|
17
18
|
if (!engineRef.current) {
|
|
18
19
|
engineRef.current = new SnowEngine(count, width, height);
|
|
19
20
|
}
|
|
@@ -21,6 +22,7 @@ export function SnowView({
|
|
|
21
22
|
let raf;
|
|
22
23
|
const loop = () => {
|
|
23
24
|
engineRef.current?.update();
|
|
25
|
+
forceRender(v => v + 1);
|
|
24
26
|
raf = requestAnimationFrame(loop);
|
|
25
27
|
};
|
|
26
28
|
loop();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","Dimensions","View","StyleSheet","Canvas","Circle","SnowEngine","jsx","_jsx","jsxs","_jsxs","SnowView","count","children","width","height","get","engineRef","current","raf","loop","update","requestAnimationFrame","cancelAnimationFrame","snow","style","flex","absoluteFill","zIndex","pointerEvents","particles","map","p","i","cx","x","cy","y","r","size","color"],"sourceRoot":"../../../src","sources":["snow/SnowView.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useState","Dimensions","View","StyleSheet","Canvas","Circle","SnowEngine","jsx","_jsx","jsxs","_jsxs","SnowView","count","children","width","height","get","engineRef","forceRender","current","raf","loop","update","v","requestAnimationFrame","cancelAnimationFrame","snow","style","flex","absoluteFill","zIndex","pointerEvents","particles","map","p","i","cx","x","cy","y","r","size","color"],"sourceRoot":"../../../src","sources":["snow/SnowView.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEnD,SAASC,UAAU,EAAEC,IAAI,EAAEC,UAAU,QAAQ,cAAc;AAC3D,SAASC,MAAM,EAAEC,MAAM,QAAQ,4BAA4B;AAC3D,SAASC,UAAU,QAAQ,iBAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE1C,OAAO,SAASC,QAAQA,CAAC;EAAEC,KAAK,GAAG,GAAG;EAAEC;AAGxC,CAAC,EAAE;EACD,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGd,UAAU,CAACe,GAAG,CAAC,QAAQ,CAAC;EAClD,MAAMC,SAAS,GAAGlB,MAAM,CAAoB,IAAI,CAAC;EACjD,MAAM,GAAGmB,WAAW,CAAC,GAAGlB,QAAQ,CAAC,CAAC,CAAC;EAEnC,IAAI,CAACiB,SAAS,CAACE,OAAO,EAAE;IACtBF,SAAS,CAACE,OAAO,GAAG,IAAIb,UAAU,CAACM,KAAK,EAAEE,KAAK,EAAEC,MAAM,CAAC;EAC1D;EAEAjB,SAAS,CAAC,MAAM;IACd,IAAIsB,GAAW;IACf,MAAMC,IAAI,GAAGA,CAAA,KAAM;MACjBJ,SAAS,CAACE,OAAO,EAAEG,MAAM,CAAC,CAAC;MAC3BJ,WAAW,CAACK,CAAC,IAAIA,CAAC,GAAG,CAAC,CAAC;MACvBH,GAAG,GAAGI,qBAAqB,CAACH,IAAI,CAAC;IACnC,CAAC;IACDA,IAAI,CAAC,CAAC;IACN,OAAO,MAAMI,oBAAoB,CAACL,GAAG,CAAC;EACxC,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMM,IAAI,GAAGT,SAAS,CAACE,OAAO;EAE9B,oBACET,KAAA,CAACR,IAAI;IAACyB,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAE,CAAE;IAAAf,QAAA,GACtBA,QAAQ,eACTL,IAAA,CAACJ,MAAM;MACLuB,KAAK,EAAE,CACLxB,UAAU,CAAC0B,YAAY,EACvB;QAAEC,MAAM,EAAE,EAAE;QAAEC,aAAa,EAAE;MAAO,CAAC,CACrC;MAAAlB,QAAA,EAEDa,IAAI,EAAEM,SAAS,CAACC,GAAG,CAAC,CAACC,CAAC,EAAEC,CAAC,kBACxB3B,IAAA,CAACH,MAAM;QAAS+B,EAAE,EAAEF,CAAC,CAACG,CAAE;QAACC,EAAE,EAAEJ,CAAC,CAACK,CAAE;QAACC,CAAC,EAAEN,CAAC,CAACO,IAAK;QAACC,KAAK,EAAC;MAAO,GAA7CP,CAA+C,CAC7D;IAAC,CACI,CAAC;EAAA,CACL,CAAC;AAEX","ignoreList":[]}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
|
|
2
|
+
export declare function SnowView({ count, children }: {
|
|
3
3
|
count?: number;
|
|
4
4
|
children?: ReactNode;
|
|
5
|
-
};
|
|
6
|
-
export declare function SnowView({ count, children }: SnowViewProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export {};
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
6
|
//# sourceMappingURL=SnowView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SnowView.d.ts","sourceRoot":"","sources":["../../../../src/snow/SnowView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SnowView.d.ts","sourceRoot":"","sources":["../../../../src/snow/SnowView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,wBAAgB,QAAQ,CAAC,EAAE,KAAW,EAAE,QAAQ,EAAE,EAAE;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,2CAqCA"}
|
package/package.json
CHANGED
package/src/snow/SnowView.tsx
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
-
type SnowViewProps = {
|
|
4
|
-
count?: number;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
};
|
|
7
3
|
import { Dimensions, View, StyleSheet } from "react-native";
|
|
8
4
|
import { Canvas, Circle } from "@shopify/react-native-skia";
|
|
9
5
|
import { SnowEngine } from "./SnowEngine";
|
|
10
|
-
export function SnowView({ count = 100, children }: SnowViewProps) {
|
|
11
6
|
|
|
7
|
+
export function SnowView({ count = 100, children }: {
|
|
8
|
+
count?: number;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}) {
|
|
12
11
|
const { width, height } = Dimensions.get("window");
|
|
13
12
|
const engineRef = useRef<SnowEngine | null>(null);
|
|
13
|
+
const [, forceRender] = useState(0);
|
|
14
14
|
|
|
15
15
|
if (!engineRef.current) {
|
|
16
16
|
engineRef.current = new SnowEngine(count, width, height);
|
|
@@ -20,6 +20,7 @@ export function SnowView({ count = 100, children }: SnowViewProps) {
|
|
|
20
20
|
let raf: number;
|
|
21
21
|
const loop = () => {
|
|
22
22
|
engineRef.current?.update();
|
|
23
|
+
forceRender(v => v + 1);
|
|
23
24
|
raf = requestAnimationFrame(loop);
|
|
24
25
|
};
|
|
25
26
|
loop();
|
|
@@ -42,5 +43,5 @@ export function SnowView({ count = 100, children }: SnowViewProps) {
|
|
|
42
43
|
))}
|
|
43
44
|
</Canvas>
|
|
44
45
|
</View>
|
|
45
|
-
);
|
|
46
|
+
);
|
|
46
47
|
}
|