Skip to content

[General] Update button's animation duration props#4046

Merged
j-piasecki merged 42 commits intomainfrom
@jpiasecki/add-minimum-animation-duration
Apr 3, 2026
Merged

[General] Update button's animation duration props#4046
j-piasecki merged 42 commits intomainfrom
@jpiasecki/add-minimum-animation-duration

Conversation

@j-piasecki
Copy link
Copy Markdown
Member

@j-piasecki j-piasecki commented Mar 30, 2026

Description

Native platforms delay touches when the button is inside a ScrollView. This may cause situations where press-out is triggered immediately after press-in, effectively running with no animation.

This PR:

  • changes the easing on web to better align with native platforms
  • changes animationDuration to pressAndHoldAnimationDuration
  • adds tapAnimationDuration

pressAndHoldAnimationDuration defaults to tapAnimationDuration when unspecified; tapAnimationDuration defaults to 100ms.

Press out handler now has three branches:

  1. pressDuration >= pressAndHoldAnimationDuration -> press out animation is started immediately with the duration of pressAndHoldAnimationDuration
  2. pressDuration * 2 in [tapAnimationDuration, pressAndHoldAnimationDuration] (*2 so there's at least half of tapAnimationDuration for the remaining animation) -> press out animation is started immediately with the duration of the press so far
  3. pressDuration < tapAnimationDuration / 2 -> pressIn animation is played fully in the remaining time in tapAnimationDuration, and pressOut is scheduled after with the duration of tapAnimationDuration

Test plan

Updated the button underlay example

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new minimumAnimationDuration prop to GestureHandlerButton to ensure the “pressed in” visual state remains visible for at least a minimum time (mitigating native touch delays inside scrollables that can cause immediate press-out).

Changes:

  • Introduces minimumAnimationDuration to the button’s codegen spec and TS props.
  • Implements minimum-duration press-out deferral on Web, iOS, and Android.
  • Updates the common-app underlay example to exercise the new prop.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/react-native-gesture-handler/src/specs/RNGestureHandlerButtonNativeComponent.ts Adds minimumAnimationDuration to native component codegen props with a default.
packages/react-native-gesture-handler/src/components/GestureHandlerButton.web.tsx Implements min-duration press-out deferral for web button visuals.
packages/react-native-gesture-handler/src/components/GestureHandlerButton.tsx Documents the new prop on the public ButtonProps interface.
packages/react-native-gesture-handler/apple/RNGestureHandlerButtonComponentView.mm Wires the new prop from Fabric props into the native button view.
packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm Adds iOS minimum-duration handling between press-in and press-out animations.
packages/react-native-gesture-handler/apple/RNGestureHandlerButton.h Exposes minimumAnimationDuration on the native button class.
packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt Adds Android prop setter + min-duration delayed press-out implementation.
apps/common-app/src/new_api/components/button_underlay/index.tsx Updates example props to demonstrate minimumAnimationDuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/react-native-gesture-handler/src/components/GestureHandlerButton.web.tsx Outdated
Comment thread packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm Outdated
@j-piasecki j-piasecki requested a review from Copilot April 1, 2026 09:37
@j-piasecki j-piasecki changed the title [General] Add minimumAnimationDuration prop to button component [General] Update button's animation duration props Apr 1, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/react-native-gesture-handler/src/components/GestureHandlerButton.tsx Outdated
Comment thread packages/react-native-gesture-handler/src/components/GestureHandlerButton.web.tsx Outdated
Comment thread apps/common-app/src/new_api/components/button_underlay/index.tsx
@j-piasecki j-piasecki requested a review from Copilot April 1, 2026 09:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@j-piasecki j-piasecki force-pushed the @jpiasecki/add-minimum-animation-duration branch from 0d51d22 to 8cd97a9 Compare April 2, 2026 09:39
Base automatically changed from @jpiasecki/refactor-button to main April 2, 2026 12:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm Outdated
@j-piasecki j-piasecki marked this pull request as ready for review April 2, 2026 13:34
@j-piasecki j-piasecki requested a review from m-bert April 2, 2026 13:34
Comment thread packages/react-native-gesture-handler/src/components/GestureHandlerButton.tsx Outdated
@j-piasecki j-piasecki merged commit d21f1dd into main Apr 3, 2026
10 checks passed
@j-piasecki j-piasecki deleted the @jpiasecki/add-minimum-animation-duration branch April 3, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants