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

Having a SafeAreaView inside ScrollView breaks scrolling #19658

Closed
WesSouza opened this issue Jun 11, 2018 · 5 comments
Closed

Having a SafeAreaView inside ScrollView breaks scrolling #19658

WesSouza opened this issue Jun 11, 2018 · 5 comments
Labels
Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.

Comments

@WesSouza
Copy link

Environment

Scanning folders for symlinks in /Users/wesley/Sites/do-app/node_modules (15ms)

Environment:
  OS: macOS High Sierra 10.13.5
  Node: 10.3.0
  Yarn: 1.7.0
  npm: 6.1.0
  Watchman: 4.9.0
  Xcode: Xcode 9.4 Build version 9F1027a
  Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: ~0.55.2 => 0.55.4

Description

SafeAreaView is dynamic, if the first element on a screen is a ScrollView, and has children SafeAreaViews, when the user scrolls down, the SafeAreaView reduces in height because it's not touching the safe area anymore, which in contrast scrolls the content back up.

Steps to Reproduce

Create an example such as

const App = () => (
  <ScrollView>
    <SafeAreaView>
      {longVerticalContent}
    </SafeAreaView>
  </ScrollView>
);

Expected Behavior

Content should scroll normally.

Actual Behavior

When you scroll slowly, the scrolling stutters and the content moves back up. If you scroll fast enough you don't see such a bad effect.

Video:
Bug reproduction video

I'd love to be able to get that information from a different source, such as Dimensions.get, so I could apply it here manually.

@hramos
Copy link
Contributor

hramos commented Jun 11, 2018

Why is your SafeAreaView inside a ScrollView? SAV should wrap your top level view.

@WesSouza
Copy link
Author

@hramos yes, that would work better, but won't have the expected visuals. The contents wouldn't overflow behind the notification bar, like the first item background.

@brunolemos
Copy link
Contributor

brunolemos commented Jun 12, 2018

Duplicate of #16997 that should not have been closed

@react-native-bot react-native-bot added the Platform: iOS iOS applications. label Jun 12, 2018
@hramos
Copy link
Contributor

hramos commented Jun 12, 2018

Duplicate of #16997 (needs write access to successfully mark as a dupe).

@hramos hramos closed this as completed Jun 12, 2018
@ceciliaschiebel
Copy link

I had the same situation, and contentInsetAdjustmentBehavior worked for me

<ScrollView contentInsetAdjustmentBehavior="automatic">
      <SafeAreaView>
            {/* long content here */}
      </SafeAreaView>
</ScrollView>

from react-native repo, ScrollView code says:

/**
   * This property specifies how the safe area insets are used to modify the
   * content area of the scroll view. The default value of this property is
   * "never". Available on iOS 11 and later.
   * @platform ios
   */
  contentInsetAdjustmentBehavior?: ?(
    | 'automatic'
    | 'scrollableAxes'
    | 'never'
    | 'always'
  ),

@facebook facebook locked as resolved and limited conversation to collaborators Sep 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jun 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

5 participants