Globe: Use Svelte transition using Motion to reveal current location Split text

This commit is contained in:
2022-09-27 10:09:36 +02:00
parent 4791fe5b13
commit fb03377d77
2 changed files with 42 additions and 15 deletions

View File

@@ -1,13 +1,18 @@
import { animate } from 'motion'
import { animate, stagger } from 'motion'
import type { TransitionConfig } from 'svelte/transition'
import { quartOut } from './easings'
/**
* Scale and fade
*/
export const scaleFade = (node: HTMLElement, {
delay = 0,
duration = 1,
scale = [0.7, 1],
opacity = [1, 0],
x = null,
}) => {
delay = 0,
duration = 1,
}): TransitionConfig => {
return {
css: () => {
animate(node, {
@@ -20,6 +25,36 @@ export const scaleFade = (node: HTMLElement, {
duration,
delay,
})
return null
}
}
}
/**
* Scale and fade split text
*/
export const revealSplit = (node: HTMLElement, {
opacity = [0, 1],
y = ['110%', '0%'],
children = '.char',
duration = 1,
delay = 0,
}): TransitionConfig => {
return {
css: () => {
animate(node.querySelectorAll(children), {
opacity,
y,
z: 0,
}, {
easing: quartOut,
duration,
delay: stagger(0.04, { start: delay }),
})
return null
}
}
}