From 2932a8cb385c34f1fb250f7378b3614ee5856cdc Mon Sep 17 00:00:00 2001 From: bcakmakoglu <78412429+bcakmakoglu@users.noreply.github.com> Date: Fri, 24 Jun 2022 23:07:49 +0200 Subject: [PATCH] chore(docs): randomize animation durations --- docs/components/home/flows/Intro.vue | 67 ++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/docs/components/home/flows/Intro.vue b/docs/components/home/flows/Intro.vue index a46c0882..96b44e99 100644 --- a/docs/components/home/flows/Intro.vue +++ b/docs/components/home/flows/Intro.vue @@ -216,6 +216,29 @@ const scrollTo = () => { el.scrollIntoView({ behavior: 'smooth' }) } } + +const animationClassNames = ['checker-gb', 'checker-op', 'checker-yg', 'checker-ss'] + +const shuffle = (a: any[]) => { + for (let i = a.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)) + ;[a[i], a[j]] = [a[j], a[i]] + } + return a +} + +const createAnimationDurations = () => { + return animationClassNames.map((className) => { + const duration = Math.random() * 8 + 1 + + return { + className, + duration, + } + }) +} + +const animations = ref<{ className: string; duration: number }[]>(shuffle(createAnimationDurations()))