starting to animate imagesection

This commit is contained in:
T-A-H-prog
2026-03-08 14:00:52 +01:00
parent 57927e4419
commit 8c8568a4b5
3 changed files with 59 additions and 5 deletions

View File

@@ -1,4 +1,6 @@
<script setup lang="ts">
<script setup lang="js">
</script>
<template>

View File

@@ -3,6 +3,8 @@ import { onMounted, onUnmounted, ref } from "vue"
import gsap from "gsap"
import ScrollTrigger from "gsap/ScrollTrigger"
gsap.registerPlugin(ScrollTrigger)
@@ -51,15 +53,16 @@ function startNextAnimation() {
tl = gsap.timeline({
scrollTrigger: {
trigger: ".scroll-trigger-ready__worm-wrap",
start: "top 00%",
start: "top top",
end: "bottom 35%",
scrub: 2
scrub: 2,
pin: true
}
})
tl.to(boxes, {
y: () => gsap.utils.random(-400, -150),
duration : 3.5,
rotate: () => gsap.utils.random(-180, 180),
ease: "none",
stagger: 0.05
@@ -79,6 +82,7 @@ onMounted(() => {
onUnmounted(() => {
ctx?.revert()
scrollTrigger.getAll().forEach(t => t.kill())
})

View File

@@ -1,4 +1,4 @@
<script setup lang="ts">
<script setup lang="js">
import ski from '../../assets/myself/ski.png'
import book from '../../assets/myself/SmartTom.jpeg'
import surf from '../../assets/myself/surf.png'
@@ -8,6 +8,54 @@ import schnee from '../../assets/myself/DSCN1921.jpg'
import water from '../../assets/myself/27-2.jpg'
import gopro from '../../assets/myself/GOPR0521.png'
import { gsap } from "gsap"
import { ScrollTrigger } from 'gsap/ScrollTrigger';
import { Flip } from 'gsap/Flip';
gsap.registerPlugin(ScrollTrigger, Flip);
let flipCtx;
const createTween = () => {
let galleryElement = document.querySelector("#gallery-8");
let galleryItems = galleryElement.querySelectorAll(".gallery__item");
console.log(flipCtx);
flipCtx && flipCtx.revert();
galleryElement.classList.remove("gallery--final");
flipCtx = gsap.context(() => {
// Temporarily add the final class to capture the final state
galleryElement.classList.add("gallery--final");
const flipState = Flip.getState(galleryItems);
galleryElement.classList.remove("gallery--final");
const flip = Flip.to(flipState, {
simple: true,
ease: "expoScale(1, 5)"
});
const tl = gsap.timeline({
scrollTrigger: {
trigger: galleryElement,
start: "center center",
end: "+=100%",
scrub: true,
pin: galleryElement.parentNode
// markers: true
}
});
tl.add(flip);
return () => gsap.set(galleryItems, { clearProps: "all" });
});
};
createTween();
window.addEventListener("resize", createTween);
</script>
<template>
<section class="image-section">