refactor: rethink ProcessStep transition + use tick in transitions
This commit is contained in:
@@ -9,24 +9,25 @@ import { quartOut } from './easings'
|
|||||||
export const scaleFade = (node: HTMLElement, {
|
export const scaleFade = (node: HTMLElement, {
|
||||||
scale = [0.7, 1],
|
scale = [0.7, 1],
|
||||||
opacity = [1, 0],
|
opacity = [1, 0],
|
||||||
x = null,
|
x = [0, 0],
|
||||||
delay = 0,
|
delay = 0,
|
||||||
duration = 1,
|
duration = 0.75,
|
||||||
}): TransitionConfig => {
|
}): TransitionConfig => {
|
||||||
return {
|
const anim = animate(node, {
|
||||||
css: () => {
|
scale,
|
||||||
animate(node, {
|
opacity,
|
||||||
scale,
|
x,
|
||||||
opacity,
|
z: 0,
|
||||||
x,
|
}, {
|
||||||
z: 0,
|
easing: quartOut,
|
||||||
}, {
|
duration,
|
||||||
easing: quartOut,
|
delay,
|
||||||
duration,
|
})
|
||||||
delay,
|
|
||||||
})
|
|
||||||
|
|
||||||
return null
|
return {
|
||||||
|
duration: anim.duration * 1000,
|
||||||
|
tick: (t) => {
|
||||||
|
anim.currentTime = t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,19 +43,20 @@ export const revealSplit = (node: HTMLElement, {
|
|||||||
duration = 1,
|
duration = 1,
|
||||||
delay = 0,
|
delay = 0,
|
||||||
}): TransitionConfig => {
|
}): TransitionConfig => {
|
||||||
return {
|
const anim = animate(node.querySelectorAll(children), {
|
||||||
css: () => {
|
opacity,
|
||||||
animate(node.querySelectorAll(children), {
|
y,
|
||||||
opacity,
|
z: 0,
|
||||||
y,
|
}, {
|
||||||
z: 0,
|
easing: quartOut,
|
||||||
}, {
|
duration,
|
||||||
easing: quartOut,
|
delay: stagger(0.04, { start: delay }),
|
||||||
duration,
|
})
|
||||||
delay: stagger(0.04, { start: delay }),
|
|
||||||
})
|
|
||||||
|
|
||||||
return null
|
return {
|
||||||
|
duration: anim.duration * 1000,
|
||||||
|
tick: (t) => {
|
||||||
|
anim.currentTime = t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,18 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { scale } from 'svelte/transition'
|
||||||
|
import { quartOut } from 'svelte/easing'
|
||||||
import { scaleFade } from '$animations/transitions'
|
import { scaleFade } from '$animations/transitions'
|
||||||
// Components
|
// Components
|
||||||
import Image from '$components/atoms/Image.svelte'
|
import Image from '$components/atoms/Image.svelte'
|
||||||
import { getAssetUrlKey } from '$utils/api'
|
import { getAssetUrlKey } from '$utils/api'
|
||||||
|
|
||||||
let {
|
let {
|
||||||
index,
|
|
||||||
text,
|
text,
|
||||||
image,
|
image,
|
||||||
video,
|
video,
|
||||||
}: {
|
}: {
|
||||||
index: number
|
|
||||||
text: string
|
text: string
|
||||||
image?: any
|
image?: any
|
||||||
video?: any
|
video?: any
|
||||||
@@ -25,9 +25,8 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
class="step grid"
|
class="step grid"
|
||||||
style:--index={index}
|
|
||||||
in:scaleFade|local={{ scale: [1.1, 1], opacity: [0, 1], x: [20, 0], delay: 0.2 }}
|
in:scaleFade|local={{ scale: [1.1, 1], opacity: [0, 1], x: [20, 0], delay: 0.2 }}
|
||||||
out:scaleFade|local={{ scale: [1, 0.9], opacity: [1, 0], x: [0, -20] }}
|
out:scale={{ start: 0.9, duration: 750, easing: quartOut }}
|
||||||
>
|
>
|
||||||
{#if image || video}
|
{#if image || video}
|
||||||
<div class="media">
|
<div class="media">
|
||||||
|
|||||||
@@ -26,7 +26,8 @@
|
|||||||
let innerWidth = $state<number>()
|
let innerWidth = $state<number>()
|
||||||
let photosGridEl: HTMLElement
|
let photosGridEl: HTMLElement
|
||||||
let photosGridParallax = $state<number>()
|
let photosGridParallax = $state<number>()
|
||||||
let currentStep = $state(0)
|
let currentStepIndex = $state(0)
|
||||||
|
const currentStep = $derived(data.about.process_steps[currentStepIndex])
|
||||||
let emailCopied = $state<string>()
|
let emailCopied = $state<string>()
|
||||||
let emailCopiedTimeout: ReturnType<typeof setTimeout> | number
|
let emailCopiedTimeout: ReturnType<typeof setTimeout> | number
|
||||||
|
|
||||||
@@ -312,13 +313,13 @@
|
|||||||
|
|
||||||
<ol>
|
<ol>
|
||||||
{#each data.about.process_steps as { title }, index}
|
{#each data.about.process_steps as { title }, index}
|
||||||
<li class:is-active={index === currentStep}>
|
<li class:is-active={index === currentStepIndex}>
|
||||||
<a
|
<a
|
||||||
class="title-big"
|
class="title-big"
|
||||||
href="#step-{index + 1}"
|
href="#step-{index + 1}"
|
||||||
onclick={(event) => {
|
onclick={(event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
currentStep = index
|
currentStepIndex = index
|
||||||
sendEvent('aboutStepSwitch')
|
sendEvent('aboutStepSwitch')
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -330,18 +331,16 @@
|
|||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<div class="steps">
|
<div class="steps">
|
||||||
{#each data.about.process_steps as { text, image, video_mp4, video_webm }, index}
|
{#key currentStep}
|
||||||
{#if index === currentStep}
|
<ProcessStep
|
||||||
<ProcessStep
|
text={currentStep.text}
|
||||||
{index} {text}
|
image={currentStep.image}
|
||||||
image={image ?? undefined}
|
video={{
|
||||||
video={{
|
mp4: currentStep.video_mp4?.id,
|
||||||
mp4: video_mp4?.id,
|
webm: currentStep.video_webm?.id
|
||||||
webm: video_webm?.id
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
{/key}
|
||||||
{/if}
|
|
||||||
{/each}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user