Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch that is checked by default causes thumb to move in wrong direction if prop "animation" is set #2509

Open
TheUnderScorer opened this issue Apr 4, 2024 · 3 comments

Comments

@TheUnderScorer
Copy link

TheUnderScorer commented Apr 4, 2024

Current Behavior

Hi!

In my app, I have a <Switch /> that is checked by default, like this:

<Switch defaultChecked>
    <Switch.Thumb animation="250ms" />
 </Switch>

If the prop animation is set on the Thumb, when Switch is toggled it looks like this:

Screen.Recording.2024-04-04.at.13.33.56.mov

However, it works as expected when I remove the animation prop.

Screen.Recording.2024-04-04.at.13.36.59.mov

The 250ms animation looks like this:

{
'250ms': {
    type: 'timing',
    duration: 250,
  },
}

I use animations from @tamagui/animations-moti.

Expected Behavior

The Thumb should move to the correct position when it's checked state changes if the Switch is checked by default, no matter if the animation prop is set or not.

Tamagui Version

1.94.3

Platform (Web, iOS, Android)

iOS

Reproduction

  1. Configure your app to use @tamagui/animations-moti as an animations driver, and set up the 250ms animation from above.
  2. Render the Switch:
<Switch defaultChecked>
    <Switch.Thumb animation="250ms" />
 </Switch>
  1. Notice that Thumb moves in wrong direction when switching

System Info

System:
    OS: macOS 14.4.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 3.25 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.6.2 - ~/.nvm/versions/node/v21.6.2/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v21.6.2/bin/npm
    pnpm: 8.15.4 - ~/.nvm/versions/node/v21.6.2/bin/pnpm
  Browsers:
    Chrome: 123.0.6312.105
    Safari: 17.4.1
@ehxxn
Copy link
Member

ehxxn commented Apr 15, 2024

this issue seems to be fixed in latest version of Tamagui, let me know if it still happens

@ehxxn ehxxn closed this as completed Apr 15, 2024
@TheUnderScorer
Copy link
Author

Hey @TheEhsanSarshar.

Unfortunately, I'm still having the same issue in 1.95.1 😢

@ps-george
Copy link

Also having the same issue in 1.95.1

@ehxxn ehxxn reopened this Apr 24, 2024
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

No branches or pull requests

3 participants