Skip to content

spike: make a page with rive only to test its CPU usage #2445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<DefaultLayout>
<NuxtLayout>
<NuxtPage />
</DefaultLayout>
</NuxtLayout>
</template>

<script setup lang="ts">
Expand Down
47 changes: 47 additions & 0 deletions pages/rive.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<template>
<canvas ref="canvas" height="1520" width="2000" :class="{
loading: !riveLoaded,
}"/>
</template>

<script setup lang="ts">
import { Rive } from "@rive-app/canvas";
import { onMounted, ref } from "vue";

definePageMeta({
layout: false
})

const canvas = ref<HTMLCanvasElement | null>(null);
const riveLoaded = ref(false);
onMounted(() => {
if(!canvas.value) {
throw new Error("Canvas element is not available");
}

const anim = new Rive({
src: "/landing/home/homepage.riv",
canvas: canvas.value,
autoplay: true,
stateMachines: "kestra",
isTouchScrollEnabled: true,
onLoad: () => {
riveLoaded.value = true
anim.resizeDrawingSurfaceToCanvas();
anim.delete();
},
});
})
</script>

<style scoped>
canvas {
border: 1px solid black;
background-color: #f0f0f0;
width: 2000px;
}
.loading {
background-color: #e0e0e0;
animation: loading 1s infinite;
}
</style>