@instantshader/react 0.1.0 → 0.3.0
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.
- package/README.md +14 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +6 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -25,3 +25,17 @@ export function Background() {
|
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
```
|
|
28
|
+
|
|
29
|
+
## Seamless loops
|
|
30
|
+
|
|
31
|
+
Pass `loopSeconds` to make the animation repeat exactly, with no visible seam
|
|
32
|
+
at the wrap:
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
<Flow colors={colors} loopSeconds={30} style={{ width: "100%", height: "100%" }} />
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
15–60s is the comfortable range, and the period is measured in animation
|
|
39
|
+
seconds (so it interacts with `speed`). See the
|
|
40
|
+
[`instantshader` README](https://www.npmjs.com/package/instantshader) for the
|
|
41
|
+
full details.
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,13 @@ interface ShaderCanvasProps {
|
|
|
20
20
|
*/
|
|
21
21
|
speed?: number;
|
|
22
22
|
seed?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Makes the animation repeat seamlessly every `loopSeconds` animation
|
|
25
|
+
* seconds. Unlike `params` and `speed`, setting this back to `undefined`
|
|
26
|
+
* DOES take effect — it turns looping off — because "no loop" is a real
|
|
27
|
+
* state the underlying handle can be put into.
|
|
28
|
+
*/
|
|
29
|
+
loopSeconds?: number;
|
|
23
30
|
paused?: boolean;
|
|
24
31
|
className?: string;
|
|
25
32
|
style?: CSSProperties;
|
|
@@ -37,6 +44,7 @@ declare function ShaderCanvas({
|
|
|
37
44
|
params,
|
|
38
45
|
speed,
|
|
39
46
|
seed,
|
|
47
|
+
loopSeconds,
|
|
40
48
|
paused,
|
|
41
49
|
className,
|
|
42
50
|
style
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
11
11
|
* or a sized parent) — this component does not impose one beyond
|
|
12
12
|
* `position: relative`.
|
|
13
13
|
*/
|
|
14
|
-
function ShaderCanvas({ shader, colors, params, speed, seed, paused, className, style }) {
|
|
14
|
+
function ShaderCanvas({ shader, colors, params, speed, seed, loopSeconds, paused, className, style }) {
|
|
15
15
|
const containerRef = useRef(null);
|
|
16
16
|
const handleRef = useRef(null);
|
|
17
17
|
const p = useMemo(() => params, [params ? Object.entries(params).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${k}:${v}`).join(",") : ""]);
|
|
@@ -23,7 +23,8 @@ function ShaderCanvas({ shader, colors, params, speed, seed, paused, className,
|
|
|
23
23
|
colors,
|
|
24
24
|
params: p,
|
|
25
25
|
speed,
|
|
26
|
-
seed
|
|
26
|
+
seed,
|
|
27
|
+
loopSeconds
|
|
27
28
|
});
|
|
28
29
|
handleRef.current = handle;
|
|
29
30
|
if (paused) handle.pause();
|
|
@@ -41,6 +42,9 @@ function ShaderCanvas({ shader, colors, params, speed, seed, paused, className,
|
|
|
41
42
|
useEffect(() => {
|
|
42
43
|
if (speed !== void 0) handleRef.current?.setSpeed(speed);
|
|
43
44
|
}, [speed]);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
handleRef.current?.setLoopSeconds(loopSeconds);
|
|
47
|
+
}, [loopSeconds]);
|
|
44
48
|
useEffect(() => {
|
|
45
49
|
if (paused) handleRef.current?.pause();
|
|
46
50
|
else handleRef.current?.resume();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instantshader/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "React bindings for InstantShader animated WebGL gradients.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"react"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"instantshader": "0.
|
|
39
|
+
"instantshader": "0.3.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": "^18 || ^19",
|