Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add default to transitionEndFilter.
  • Loading branch information
DaniGuardiola committed Oct 2, 2024
commit eec04017f611a4dcdb71f47a349e09e62fa0a953
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function useAnimatedOffsetRect(
{
prefix = 'subelement',
attribute = `${ prefix }-animated`,
transitionEndFilter,
transitionEndFilter = () => true,
}: {
/**
* The prefix used for the CSS variables, e.g. if `prefix` is `selected`, the
Expand All @@ -75,11 +75,12 @@ function useAnimatedOffsetRect(
attribute?: string;
Comment thread
DaniGuardiola marked this conversation as resolved.
Outdated
/**
* A function that is called with the transition event and returns a boolean
* indicating whether the animation should be stopped. The default is to
* always stop the animation.
* indicating whether the animation should be stopped. The default is a function
* that always returns `true`.
*
* For example, if the animated element is the `::before` pseudo-element, the
* function can be written as `( event ) => event.pseudoElement === '::before'`.
* @default () => true
*/
transitionEndFilter?: ( event: TransitionEvent ) => boolean;
} = {}
Expand All @@ -105,7 +106,7 @@ function useAnimatedOffsetRect(
} );
useLayoutEffect( () => {
function onTransitionEnd( event: TransitionEvent ) {
if ( transitionEndFilter?.( event ) ?? true ) {
if ( transitionEndFilter( event ) ) {
container?.removeAttribute( `data-${ attribute }` );
}
}
Expand Down