X Tutup
Skip to content

fix(Slider): Animate transform, not width/height#3929

Open
pastelmind wants to merge 3 commits intoreact-native-elements:nextfrom
pastelmind:fix-slider-animate-transform
Open

fix(Slider): Animate transform, not width/height#3929
pastelmind wants to merge 3 commits intoreact-native-elements:nextfrom
pastelmind:fix-slider-animate-transform

Conversation

@pastelmind
Copy link

When resizing the mininum track of <Slider/>, animate transform properties (scaleX, scaleY) instead of width and height. This is needed because width and height cannot be animated with the native driver.

This fixes a bug that caused errors in iOS and Android simulators when animateTransitions is enabled.

Motivation

Fixes #3928

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Jest Unit Test
  • Checked with example app

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation using yarn docs-build-api
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Additional context

When resizing the mininum track of <Slider/>, animate transform
properties (scaleX, scaleY) instead of width and height. This is needed
because width and height cannot be animated with the native driver.

This fixes a bug that caused errors in iOS and Android simulators when
`animateTransitions` is enabled.
@pastelmind
Copy link
Author

pastelmind commented Sep 4, 2024

Looks like this causes a visual glitch with the minimum track. Since the tracks are being stretched with scaleX and scaleY, the circular corners (made with borderRadius) are distorted.

I "fixed" the glitch (ba83637) by moving the minimum track inside the maximum track, and setting borderRadius: 0 on the (inner) minimum track and overflow: 'hidden' on the (outer) maximum track. Compare:

Before fix After fix
before fix after fix

Update: ba83637 makes trackSize unnecessary, so I also removed the track size measuring logic (99b67b7).

Using scaleX/scaleY to transform the minimum track causes the border
radius to be distorted. In order to render round track corners, this PR
moves the minimum track inside the maximum track, removes the border
radius from the inner track, and sets `overflow: 'hidden'` on the
maximum track.
Since the previous commits made it unnecessary to use the measured track
size, let's remove the track size measuring logic altogether.
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.

Error when <Slider> has animateTransitions

1 participant

X Tutup