Getting RunTime Error
RuntimeError: memory access out of bounds
here is the code
import { useRive, useStateMachineInput, Fit, Layout as RiveLayout, Alignment } from "@rive-app/react-canvas"; import { useEffect } from "react"; import s from './HeroScrollRive.module.scss' import { useScroll } from '@/hooks/use-scroll' export default function HeroScrollingRive(props) { const { rive, RiveComponent } = useRive({ src: "/eyenai.riv", artboard: "HeroAnimation", stateMachines: "ScrollingBehaviour", layout: new RiveLayout({ fit: Fit.FitHeight, alignment: Alignment.CenterRight, }), autoplay: true, }) const scrollPos = useStateMachineInput( rive, "ScrollingBehaviour", "ScrollPos", 0 ) useEffect(() => { let scrollListener; if (scrollPos) { const body = document.querySelector("body"); const bodyParent = body.parentNode; const pageLength = bodyParent.scrollHeight; const scrollCallback = () => { const scrollOffset = bodyParent.scrollTop; const scrollPosValue = (450 * scrollOffset) / (pageLength - bodyParent.clientHeight); scrollPos.value = scrollPosValue; }; scrollListener = document.addEventListener("scroll", scrollCallback); } return () => { if (scrollListener) { document.removeEventListener("scroll", scrollListener); console.log(scrollListener); } }; }, [scrollPos]); return ( <RiveComponent className={s.hero__rive} /> ); }
Getting these type of errors
I followed the tutorial from the Rive Animation on Scroll things suppose to be working but not the way I want, I'm exporting it as a component and idk how i can trigger this aniamtion at certain level of scroll to let it animate according to that point to the end of the animation on scroll
Hi
One thing I would take a look at is to make sure the name of your state machine and input in your .rev file matches what you have in your code (ie, "ScrollingBehavior" as the state machine name and "ScrollPos" as the input name).
Hello
here is my riv file
https://drive.google.com/file/d/1jVuMy41f_h8ZIVEsiskApe5Hk8LhLLF4/view?usp=sharing