-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathRive.tsx
More file actions
65 lines (60 loc) · 1.69 KB
/
Copy pathRive.tsx
File metadata and controls
65 lines (60 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { Layout } from '@rive-app/canvas';
import React, { ComponentProps } from 'react';
import useRive from '../hooks/useRive';
export interface RiveProps {
/**
* URL of the Rive asset, or path to where the public asset is stored.
*/
src: string;
/**
* Artboard to render from the Rive asset.
* Defaults to the first artboard created.
*/
artboard?: string;
/**
* Specify a starting animation to play.
*/
animations?: string | string[];
/**
* Specify a starting state machine to play.
*/
stateMachines?: string | string[];
/**
* Specify a starting Layout object to set Fill and Alignment for the drawing surface. See docs at https://help.rive.app/runtimes/layout for more on layout configuration.
*/
layout?: Layout;
/**
* For `@rive-app/react-webgl`, sets this property to maintain a single WebGL context for multiple canvases. **We recommend to keep the default value** when rendering multiple Rive instances on a page.
*/
useOffscreenRenderer?: boolean;
/**
* If true, the runtime will respect the users "prefers-reduced-motion" accessibilty option and start the animation paused. Defaults to false.
*/
usePrefersReducedMotion?: boolean;
}
const Rive = ({
src,
artboard,
animations,
stateMachines,
layout,
useOffscreenRenderer = true,
usePrefersReducedMotion = false,
...rest
}: RiveProps & ComponentProps<'canvas'>) => {
const params = {
src,
artboard,
animations,
layout,
stateMachines,
autoplay: true,
};
const options = {
useOffscreenRenderer,
usePrefersReducedMotion,
};
const { RiveComponent } = useRive(params, options);
return <RiveComponent {...rest} />;
};
export default Rive;