1
- import { clsx } from "clsx"
2
- import { cubicOut } from "svelte/easing"
3
- import { twMerge } from "tailwind-merge"
4
-
5
- import type { ClassValue } from "clsx"
6
- import type { TransitionConfig } from "svelte/transition"
1
+ import type { ClassValue } from 'clsx'
2
+ import { clsx } from 'clsx'
3
+ import { cubicOut } from 'svelte/easing'
4
+ import type { TransitionConfig } from 'svelte/transition'
5
+ import { twMerge } from 'tailwind-merge'
7
6
8
7
export function cn ( ...inputs : ClassValue [ ] ) {
9
8
return twMerge ( clsx ( inputs ) )
@@ -16,35 +15,34 @@ type FlyAndScaleParams = {
16
15
duration ?: number
17
16
}
18
17
19
- export const flyAndScale = (
20
- node : Element ,
21
- params : FlyAndScaleParams = { y : - 8 , x : 0 , start : 0.95 , duration : 150 } ,
22
- ) : TransitionConfig => {
23
- const style = getComputedStyle ( node )
24
- const transform = style . transform === "none" ? "" : style . transform
18
+ function scaleConversion ( valueA : number , scaleA : [ number , number ] , scaleB : [ number , number ] ) {
19
+ const [ minA , maxA ] = scaleA
20
+ const [ minB , maxB ] = scaleB
25
21
26
- const scaleConversion = (
27
- valueA : number ,
28
- scaleA : [ number , number ] ,
29
- scaleB : [ number , number ] ,
30
- ) => {
31
- const [ minA , maxA ] = scaleA
32
- const [ minB , maxB ] = scaleB
22
+ const percentage = ( valueA - minA ) / ( maxA - minA )
23
+ const valueB = percentage * ( maxB - minB ) + minB
33
24
34
- const percentage = ( valueA - minA ) / ( maxA - minA )
35
- const valueB = percentage * ( maxB - minB ) + minB
25
+ return valueB
26
+ }
36
27
37
- return valueB
38
- }
28
+ function styleToString ( style : Record < string , number | string | undefined > ) : string {
29
+ // eslint-disable-next-line unicorn/no-array-reduce
30
+ return Object . keys ( style ) . reduce ( ( str , key ) => {
31
+ if ( style [ key ] === undefined )
32
+ return str
33
+ return `${ str } ${ key } :${ style [ key ] } ;`
34
+ } , '' )
35
+ }
39
36
40
- const styleToString = (
41
- style : Record < string , number | string | undefined > ,
42
- ) : string => {
43
- return Object . keys ( style ) . reduce ( ( str , key ) => {
44
- if ( style [ key ] === undefined ) return str
45
- return str + `${ key } :${ style [ key ] } ;`
46
- } , "" )
37
+ export function flyAndScale ( node : Element , params ?: FlyAndScaleParams ) : TransitionConfig {
38
+ params = params ?? {
39
+ y : - 8 ,
40
+ x : 0 ,
41
+ start : 0.95 ,
42
+ duration : 150 ,
47
43
}
44
+ const style = getComputedStyle ( node )
45
+ const transform = style . transform === 'none' ? '' : style . transform
48
46
49
47
return {
50
48
duration : params . duration ?? 200 ,
0 commit comments