From 7df382ee1f0656350c58b42a749d0c138b4861dd Mon Sep 17 00:00:00 2001 From: Sped0n Date: Fri, 3 Nov 2023 08:58:10 +0800 Subject: [PATCH] feat(utils.ts): add loadGsap and loadSwiper function to asynchronously load library --- assets/ts/utils.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/assets/ts/utils.ts b/assets/ts/utils.ts index 9cdfef3..8f02ce8 100644 --- a/assets/ts/utils.ts +++ b/assets/ts/utils.ts @@ -1,3 +1,6 @@ +import { type Power3, type gsap } from 'gsap' +import { type Swiper } from 'swiper' + /** * custom helpers */ @@ -36,6 +39,16 @@ export function onVisible( }).observe(element) } +export async function loadGsap(): Promise<[typeof gsap, typeof Power3]> { + const g = await import('gsap') + return [g.gsap, g.Power3] +} + +export async function loadSwiper(): Promise { + const s = await import('swiper') + return s.Swiper +} + /** * custom types */