Want to try fastn for your company's website?
Book a Demo

ftd.rive - Rive Animations

ftd.rive is a kernel component used to render Rive animation in a fastn document.
Hello Rive!
Input
-- import: fastn.com/assets

-- ftd.rive:
id: panda
background.solid: #aaa
src: $assets.files.rive.panda.riv
width.fixed.px: 400
Lang:
ftd
Output
ftd.rive accepts all the common attributes, and the ones listed below.

id

Type: Required string

The unique id used to identify this rive object. This id is used in communication with the Rive state machine.

src

Type: Required string

This is URL of riv file to load. It is recommended you store the riv file as part of your fastn package and use the auto generated assets module to refer to them.

state-machine

Type: string list

It accepts the name or list of names of Rive state machines to load.

autoplay

Type: boolean default: true

If set true, the animation will automatically start playing when loaded.

artboard

Type: optional string

It accepts the name of the rive artboard to use.

Rive functions

fastn language has various rive related built-in functions. These functions help to interact with rive on various events.
Sample code
Input
-- ftd.rive:
id: fastn
src: $fastn-assets.files.assets.fastn.riv
width.fixed.px: 440
state-machine: Together
$on-mouse-enter$: $ftd.set-rive-boolean(rive = fastn, input = play, value = true)
$on-mouse-leave$: $ftd.set-rive-boolean(rive = fastn, input = play, value = false)
Lang:
ftd
Output

Rive Events

fastn language has various rive related events. These events can be attached to rive component. They fire the callback when any event occurs in rive component.