feat(intro): implement intro screen
This commit is contained in:
68
app/stores/intro.ts
Normal file
68
app/stores/intro.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import gsap from "gsap";
|
||||
|
||||
export const useIntroStore = defineStore("intro", {
|
||||
state: () => ({
|
||||
intro: {
|
||||
textOpacity: 0,
|
||||
logoFrameIndex: 0,
|
||||
},
|
||||
|
||||
outro: {
|
||||
textOpacity: 1,
|
||||
},
|
||||
|
||||
isIntro: true,
|
||||
isOutro: false,
|
||||
}),
|
||||
|
||||
actions: {
|
||||
animateIntro() {
|
||||
this.isIntro = true;
|
||||
|
||||
const { assets } = useAssets();
|
||||
const totalFrames = Object.keys(assets.images.intro.logoAnimated).length;
|
||||
const logoDuration = totalFrames / 25;
|
||||
|
||||
gsap
|
||||
.timeline()
|
||||
.to({}, { duration: 2 })
|
||||
.to(
|
||||
this.intro,
|
||||
{
|
||||
textOpacity: 1,
|
||||
duration: 0.1,
|
||||
ease: "none",
|
||||
},
|
||||
3,
|
||||
)
|
||||
.to(
|
||||
this.intro,
|
||||
{
|
||||
logoFrameIndex: totalFrames - 1,
|
||||
duration: logoDuration,
|
||||
ease: "steps(" + (totalFrames - 1) + ")",
|
||||
},
|
||||
3,
|
||||
)
|
||||
.call(() => {
|
||||
this.isIntro = false;
|
||||
});
|
||||
},
|
||||
|
||||
animateOutro() {
|
||||
this.isOutro = true;
|
||||
|
||||
gsap
|
||||
.timeline()
|
||||
.to(this.outro, {
|
||||
textOpacity: 0,
|
||||
duration: 0.25,
|
||||
ease: "none",
|
||||
})
|
||||
.call(() => {
|
||||
const app = useAppStore();
|
||||
app.booted = true;
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user