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

ScrollView snapToInterval/snapToOffsets not working when the scrollView width is a float number in IOS. #48393

Open
hiyuki opened this issue Dec 26, 2024 · 3 comments
Labels
Component: ScrollView Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Newer Patch Available Platform: iOS iOS applications.

Comments

@hiyuki
Copy link

hiyuki commented Dec 26, 2024

Description

ScrollView snapToInterval/snapToOffsets not working when the scrollView width is a float number in IOS, because isHorizontal method in RCTEnhancedScrollView return a unexpected result when the width is a float.

- (BOOL)isHorizontal:(UIScrollView *)scrollView
{
  return scrollView.contentSize.width > self.frame.size.width;
}

In my reproducer: https://snack.expo.dev/@hiyuki/scrollview-snaptointerval-bug, when i set scrollView's width with a integer, such as 100, snapToInterval/snapToOffsets works fine, but when i set the width with a float number, such as 100.3, snapToInterval/snapToOffsets does't work.

Steps to reproduce

  1. open the reproducer link: https://snack.expo.dev/@hiyuki/scrollview-snaptointerval-bug
  2. execute it with expo go in a IOS device
  3. scroll the scrollView content vertically, snapToInterval/snapToOffsets does't work when touch up

React Native Version

0.76.5

Affected Platforms

Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 14.3.1
  CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Memory: 1.77 GB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.17.1
    path: /usr/local/bin/node
  Yarn: Not Found
  npm:
    version: 9.8.1
    path: /usr/local/bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK:
    API Levels:
      - "34"
      - "35"
    Build Tools:
      - 33.0.1
      - 34.0.0
      - 35.0.0
    System Images:
      - android-34 | Intel x86_64 Atom
      - android-34 | Google APIs Intel x86_64 Atom
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2412.12266719
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.0-alpha.2
    wanted: 15.0.0-alpha.2
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.5
    wanted: ^0.76.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

no crash

Reproducer

https://snack.expo.dev/@hiyuki/scrollview-snaptointerval-bug

Screenshots and Videos

set ScrollView's width with 100.3, snapToInterval/snapToOffsets does't work.

63_1735194854.mp4

set ScrollView's width with 100, snapToInterval/snapToOffsets works fine.

64_1735194855.mp4
@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - 0.76.5. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@princektripathi
Copy link

@shubhamguptadream11, I have validated the repro, please update the label.
This seems to behaving oddly in iOS when decimal width is provided for ScrollView.

@shubhamguptadream11 shubhamguptadream11 added Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. and removed Needs: Triage 🔍 labels Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: ScrollView Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Newer Patch Available Platform: iOS iOS applications.
Projects
None yet
Development

No branches or pull requests

4 participants