Skip to content

Commit

Permalink
Add scroll-driven animation experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
LSViana committed Nov 25, 2023
1 parent b6d8e23 commit 8dbb1bd
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
39 changes: 39 additions & 0 deletions components/experiments/scroll/WlScrollDrivenAnimation.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<template>
<div class="wl-sda-root relative">
<div class="wl-sda-progress absolute h-1 w-full bg-amber-500" />
<div class="wl-sda flex gap-3 overflow-x-scroll py-3">
<div
v-for="i in 10"
:key="i"
class="h-32 w-32 shrink-0 rounded border bg-slate-200 dark:bg-slate-800"
/>
</div>
</div>
</template>

<style lang="scss" scoped>
@keyframes sda-progress {
from {
background-color: theme('colors.red.500');
width: 0;
}
to {
background-color: theme('colors.amber.500');
width: 100%;
}
}
.wl-sda-root {
timeline-scope: --wl-sda;
}
.wl-sda {
scroll-timeline: --wl-sda inline;
}
.wl-sda-progress {
animation: sda-progress linear;
animation-timeline: --wl-sda;
}
</style>
10 changes: 10 additions & 0 deletions pages/experiments/scroll/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
Used to show multiple cards in an animated stack list as the box scrolls.
</template>
</ExperimentCanvas>
<p>
The
<a href="https://developer.chrome.com/articles/scroll-driven-animations/" class="underline" target="_blank">
<span>scroll-driven animation</span>
</a>:
</p>
<ExperimentCanvas>
<WlScrollDrivenAnimation />
</ExperimentCanvas>
</Container>
</NuxtLayout>
</template>
Expand All @@ -25,4 +34,5 @@
import Container from '~/components/shared/layout/Container.vue'
import ExperimentCanvas from '~/components/shared/experiments/ExperimentCanvas.vue'
import WlScrollStackAnimatedContainer from '~/components/experiments/scroll/WlScrollStackAnimatedContainer.vue'
import WlScrollDrivenAnimation from '~/components/experiments/scroll/WlScrollDrivenAnimation.vue'
</script>

1 comment on commit 8dbb1bd

@vercel
Copy link

@vercel vercel bot commented on 8dbb1bd Nov 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

web-labs – ./

web-labs-lsviana.vercel.app
web-labs-git-main-lsviana.vercel.app
web-labs.vercel.app

Please sign in to comment.