Use reveal function to animate in ScrollingTitle
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { map } from '$utils/functions'
|
import { map } from '$utils/functions'
|
||||||
|
import { reveal, fly } from '$animations/index'
|
||||||
|
|
||||||
export let tag: string
|
export let tag: string
|
||||||
export let label: string = undefined
|
export let label: string = undefined
|
||||||
export let parallax: number = undefined
|
export let parallax: number = undefined
|
||||||
export let offset: number = 0
|
export let offset: number = 0
|
||||||
|
export let animate: boolean = true
|
||||||
|
|
||||||
let scrollY: number
|
let scrollY: number
|
||||||
let titleEl: HTMLElement
|
let titleEl: HTMLElement
|
||||||
@@ -20,21 +22,37 @@
|
|||||||
'title-huge',
|
'title-huge',
|
||||||
$$props.class
|
$$props.class
|
||||||
].join(' ').trim()
|
].join(' ').trim()
|
||||||
|
|
||||||
|
|
||||||
|
const revealOptions = animate ? {
|
||||||
|
animation: fly,
|
||||||
|
options: {
|
||||||
|
children: '.char',
|
||||||
|
stagger: 60,
|
||||||
|
duration: 1600,
|
||||||
|
from: '-100%',
|
||||||
|
opacity: false,
|
||||||
|
delay: 200,
|
||||||
|
},
|
||||||
|
threshold: 0.2,
|
||||||
|
} : {}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window bind:scrollY />
|
<svelte:window bind:scrollY />
|
||||||
|
|
||||||
{#if tag === 'h1'}
|
{#if tag === 'h1'}
|
||||||
<h1 class={classes} aria-label={label}
|
<h1 bind:this={titleEl}
|
||||||
bind:this={titleEl}
|
class={classes} aria-label={label}
|
||||||
style="--parallax-x: {parallax};"
|
style="--parallax-x: {parallax};"
|
||||||
|
use:reveal={revealOptions}
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</h1>
|
</h1>
|
||||||
{:else if tag === 'p'}
|
{:else if tag === 'p'}
|
||||||
<p class={classes} aria-label={label}
|
<p bind:this={titleEl}
|
||||||
bind:this={titleEl}
|
class={classes} aria-label={label}
|
||||||
style="--parallax-x: {parallax};"
|
style="--parallax-x: {parallax};"
|
||||||
|
use:reveal={revealOptions}
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
const { path } = $page
|
const { path } = $page
|
||||||
|
|
||||||
let scrollY: number, innerHeight: number
|
let scrollY: number, innerHeight: number
|
||||||
let introTitleParallax = 0
|
|
||||||
|
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
@@ -34,13 +33,6 @@
|
|||||||
easing: 'easeOutQuart',
|
easing: 'easeOutQuart',
|
||||||
})
|
})
|
||||||
|
|
||||||
// Animate h1 title
|
|
||||||
introTimeline.add({
|
|
||||||
targets: '.homepage__title--houses .char',
|
|
||||||
translateY: ['-100%', 0],
|
|
||||||
delay: anime.stagger(60),
|
|
||||||
}, 200)
|
|
||||||
|
|
||||||
// Reveal text
|
// Reveal text
|
||||||
introTimeline.add({
|
introTimeline.add({
|
||||||
targets: '.homepage__headline',
|
targets: '.homepage__headline',
|
||||||
@@ -77,7 +69,12 @@
|
|||||||
out:fade={{ duration: DURATION.PAGE_OUT }}
|
out:fade={{ duration: DURATION.PAGE_OUT }}
|
||||||
>
|
>
|
||||||
<section class="homepage__intro">
|
<section class="homepage__intro">
|
||||||
<ScrollingTitle tag="h1" class="homepage__title--houses" label="Houses of the World" parallax={introTitleParallax} offsetTop={100}>
|
<ScrollingTitle
|
||||||
|
tag="h1"
|
||||||
|
class="homepage__title--houses"
|
||||||
|
label="Houses of the World"
|
||||||
|
offsetTop={100}
|
||||||
|
>
|
||||||
<SplitText text="Houses" mode="chars" />
|
<SplitText text="Houses" mode="chars" />
|
||||||
</ScrollingTitle>
|
</ScrollingTitle>
|
||||||
|
|
||||||
@@ -135,7 +132,11 @@
|
|||||||
<section class="homepage__locations" id="locations">
|
<section class="homepage__locations" id="locations">
|
||||||
<InteractiveGlobe />
|
<InteractiveGlobe />
|
||||||
|
|
||||||
<ScrollingTitle tag="p" class="homepage__title--world" parallax={introTitleParallax} offset={-1 * innerHeight / 2}>
|
<ScrollingTitle
|
||||||
|
tag="p"
|
||||||
|
class="homepage__title--world"
|
||||||
|
offset={-1 * innerHeight / 2}
|
||||||
|
>
|
||||||
<SplitText text="World" mode="chars" />
|
<SplitText text="World" mode="chars" />
|
||||||
</ScrollingTitle>
|
</ScrollingTitle>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user