react-native-snow-backgroud 0.1.1 → 0.1.2
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,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
|
-
import { Dimensions } from "react-native";
|
|
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";
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
8
|
export function SnowView({
|
|
9
|
-
count = 100
|
|
9
|
+
count = 100,
|
|
10
|
+
children
|
|
10
11
|
}) {
|
|
11
12
|
const {
|
|
12
13
|
width,
|
|
@@ -26,16 +27,17 @@ export function SnowView({
|
|
|
26
27
|
return () => cancelAnimationFrame(raf);
|
|
27
28
|
}, []);
|
|
28
29
|
const snow = engineRef.current;
|
|
29
|
-
return /*#__PURE__*/
|
|
30
|
-
style:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
31
|
+
style: StyleSheet.absoluteFill,
|
|
32
|
+
children: [/*#__PURE__*/_jsx(Canvas, {
|
|
33
|
+
style: StyleSheet.absoluteFill,
|
|
34
|
+
children: snow?.particles.map((p, i) => /*#__PURE__*/_jsx(Circle, {
|
|
35
|
+
cx: p.x,
|
|
36
|
+
cy: p.y,
|
|
37
|
+
r: p.size,
|
|
38
|
+
color: "white"
|
|
39
|
+
}, i))
|
|
40
|
+
}), children]
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
43
|
//# sourceMappingURL=SnowView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","Dimensions","Canvas","Circle","SnowEngine","jsx","_jsx","SnowView","count","width","height","get","engineRef","current","raf","loop","update","requestAnimationFrame","cancelAnimationFrame","snow","style","
|
|
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","absoluteFill","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;AAMzC,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;AAC1C,OAAO,SAASC,QAAQA,CAAC;EAAEC,KAAK,GAAG,GAAG;EAAEC;AAAwB,CAAC,EAAE;EAEjE,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGd,UAAU,CAACe,GAAG,CAAC,QAAQ,CAAC;EAClD,MAAMC,SAAS,GAAGjB,MAAM,CAAoB,IAAI,CAAC;EAEjD,IAAI,CAACiB,SAAS,CAACC,OAAO,EAAE;IACtBD,SAAS,CAACC,OAAO,GAAG,IAAIZ,UAAU,CAACM,KAAK,EAAEE,KAAK,EAAEC,MAAM,CAAC;EAC1D;EAEAhB,SAAS,CAAC,MAAM;IACd,IAAIoB,GAAW;IACf,MAAMC,IAAI,GAAGA,CAAA,KAAM;MACjBH,SAAS,CAACC,OAAO,EAAEG,MAAM,CAAC,CAAC;MAC3BF,GAAG,GAAGG,qBAAqB,CAACF,IAAI,CAAC;IACnC,CAAC;IACDA,IAAI,CAAC,CAAC;IACN,OAAO,MAAMG,oBAAoB,CAACJ,GAAG,CAAC;EACxC,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMK,IAAI,GAAGP,SAAS,CAACC,OAAO;EAE9B,oBACER,KAAA,CAACR,IAAI;IAACuB,KAAK,EAAEtB,UAAU,CAACuB,YAAa;IAAAb,QAAA,gBACnCL,IAAA,CAACJ,MAAM;MAACqB,KAAK,EAAEtB,UAAU,CAACuB,YAAa;MAAAb,QAAA,EACpCW,IAAI,EAAEG,SAAS,CAACC,GAAG,CAAC,CAACC,CAAC,EAAEC,CAAC,kBACxBtB,IAAA,CAACH,MAAM;QAAS0B,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,EAERjB,QAAQ;EAAA,CACL,CAAC;AAEX","ignoreList":[]}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
type SnowViewProps = {
|
|
2
3
|
count?: number;
|
|
3
|
-
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
};
|
|
6
|
+
export declare function SnowView({ count, children }: SnowViewProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
4
8
|
//# sourceMappingURL=SnowView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SnowView.d.ts","sourceRoot":"","sources":["../../../../src/snow/SnowView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SnowView.d.ts","sourceRoot":"","sources":["../../../../src/snow/SnowView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,KAAK,aAAa,GAAG;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAIF,wBAAgB,QAAQ,CAAC,EAAE,KAAW,EAAE,QAAQ,EAAE,EAAE,aAAa,2CAgChE"}
|
package/package.json
CHANGED
package/src/snow/SnowView.tsx
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
type SnowViewProps = {
|
|
4
|
+
count?: number;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
import { Dimensions, View, StyleSheet } from "react-native";
|
|
3
8
|
import { Canvas, Circle } from "@shopify/react-native-skia";
|
|
4
9
|
import { SnowEngine } from "./SnowEngine";
|
|
10
|
+
export function SnowView({ count = 100, children }: SnowViewProps) {
|
|
5
11
|
|
|
6
|
-
export function SnowView({ count = 100 }: { count?: number }) {
|
|
7
12
|
const { width, height } = Dimensions.get("window");
|
|
8
13
|
const engineRef = useRef<SnowEngine | null>(null);
|
|
9
14
|
|
|
@@ -24,10 +29,14 @@ export function SnowView({ count = 100 }: { count?: number }) {
|
|
|
24
29
|
const snow = engineRef.current;
|
|
25
30
|
|
|
26
31
|
return (
|
|
27
|
-
<
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
<View style={StyleSheet.absoluteFill}>
|
|
33
|
+
<Canvas style={StyleSheet.absoluteFill}>
|
|
34
|
+
{snow?.particles.map((p, i) => (
|
|
35
|
+
<Circle key={i} cx={p.x} cy={p.y} r={p.size} color="white" />
|
|
36
|
+
))}
|
|
37
|
+
</Canvas>
|
|
38
|
+
|
|
39
|
+
{children}
|
|
40
|
+
</View>
|
|
41
|
+
);
|
|
33
42
|
}
|