Skip to content

Commit 148eccc

Browse files
scroll trigger implemented
1 parent ef76abf commit 148eccc

File tree

10 files changed

+10104
-2
lines changed

10 files changed

+10104
-2
lines changed

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Nuxt dev/build outputs
2+
.output
3+
.data
4+
.nuxt
5+
.nitro
6+
.cache
7+
dist
8+
9+
# Node dependencies
10+
node_modules
11+
12+
# Logs
13+
logs
14+
*.log
15+
16+
# Misc
17+
.DS_Store
18+
.fleet
19+
.idea
20+
21+
# Local env files
22+
.env
23+
.env.*
24+
!.env.example

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# nuxt-gsap-scroll-trigger
2-
ScrollTrigger setup in a Nuxt3 App
1+
# Nuxt 3 with GSAP ScrollSmoother

app.vue

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<script setup>
2+
import { onMounted, onUnmounted, ref } from 'vue';
3+
import gsap from 'gsap';
4+
import { ScrollTrigger } from 'gsap/ScrollTrigger';
5+
6+
gsap.registerPlugin(ScrollTrigger);
7+
8+
const main = ref();
9+
let ctx;
10+
11+
onMounted(() => {
12+
ctx = gsap.context((self) => {
13+
const boxes = self.selector('.box');
14+
boxes.forEach((box) => {
15+
gsap.to(box, {
16+
x: 150,
17+
scrollTrigger: {
18+
trigger: box,
19+
start: 'bottom bottom',
20+
end: 'top 20%',
21+
scrub: true,
22+
},
23+
});
24+
});
25+
}, main.value); // <- Scope!
26+
});
27+
28+
onUnmounted(() => {
29+
ctx.revert(); // <- Easy Cleanup!
30+
});
31+
</script>
32+
33+
<template>
34+
<section class="panel center column gradient-blue text-dark">
35+
<h1>Basic ScrollTrigger in Nuxt 3</h1>
36+
<h2>Scroll down to see the magic happen!!</h2>
37+
<a href="#">Author: Muhammad Awais</a>
38+
</section>
39+
<div class="panel center column" ref="main">
40+
<div class="box gradient-green">box</div>
41+
<div class="box gradient-green">box</div>
42+
<div class="box gradient-green">box</div>
43+
</div>
44+
<section class="panel center gradient-orange column text-dark">
45+
<h1>The End!</h1>
46+
<h2 class="center">
47+
For more information visit:&nbsp;
48+
<a href="https://greensock.com/scrolltrigger/" target="_blank" rel="noreferrer">
49+
greensock.com/scrolltrigger/
50+
</a>
51+
</h2>
52+
</section>
53+
</template>
54+
55+
<style>
56+
@import url('~/assets/styles.css');
57+
</style>

0 commit comments

Comments
 (0)