@@ -3,7 +3,6 @@ import { CSSProperties } from "react"
33import { ease } from "utils/ease"
44
55const DURATION = 1000
6- const TIMING_FUNCTION = `cubic-bezier(${ ease . out . join ( "," ) } )`
76
87type AllowedElement = HTMLElement | SVGElement
98
@@ -22,6 +21,7 @@ const applyStyles = (node: AllowedElement, styles: CSSProperties) => {
2221interface TransitionProps < TElement extends AllowedElement > {
2322 initStyles : CSSProperties | ( ( node : TElement ) => CSSProperties )
2423 targetStyles : CSSProperties | ( ( node : TElement ) => CSSProperties )
24+ timingFunction ?: keyof typeof ease
2525}
2626
2727interface InitTransitionProps < TElement extends AllowedElement > {
@@ -33,6 +33,7 @@ interface InitTransitionProps<TElement extends AllowedElement> {
3333export const createTransition = < TElement extends AllowedElement > ( {
3434 initStyles,
3535 targetStyles,
36+ timingFunction = "out" ,
3637} : TransitionProps < TElement > ) => {
3738 const initTransition = ( node : TElement ) => {
3839 const styles =
@@ -56,7 +57,7 @@ export const createTransition = <TElement extends AllowedElement>({
5657 transitionProperty : toCssProperties ( styles ) ,
5758 transitionDuration : `${ DURATION } ms` ,
5859 transitionDelay : `${ itemDelay } ms` ,
59- transitionTimingFunction : TIMING_FUNCTION ,
60+ transitionTimingFunction : `cubic-bezier( ${ ease [ timingFunction ] . join ( "," ) } )` ,
6061 } )
6162 }
6263
0 commit comments