question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Absolute elements jump on the screen with a large title when scrolling

See original GitHub issue

After scrolling ‘faster’, the position of the screen and/or button changes position more, in a clean application with simple empty screen it occurs less often, while in a larger app it occurs almost every time.

Code:

function First({ navigation }) {
    return (
        <>
            <ScrollView style={{ backgroundColor: 'pink', flex: 1 }}>
                <Text>First</Text>
            </ScrollView>
            <Text style={{ position: 'absolute', padding: 30, backgroundColor: 'red', bottom: 100, alignSelf: 'center' }}>Some Absolute Text</Text>
        </>
    );
}

export function BugStack() {
    return (
        <NativeStack.Navigator>
            <NativeStack.Screen name='First' component={First} options={{ headerLargeTitle: true }} />
        </NativeStack.Navigator>
    );
}

Gif with 0.5x speed: ezgif-4-a44db65b9766

- @react-navigation/native: 5.2.6
- @react-navigation/stack: 5.3.1
- react-native-screens: 2.7.0

platform: iOS
mode: Debug and Release (issue on both)
Device: iPhone XS
OS version: 13.4.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
timothyaccommented, Aug 27, 2020

Nevermind I see what has to be done. For anybody else that is having the same problem but hasn’t read the docs fully (me. <= bad). Your ScrollView needs to have contentInsetAdjustmentBehavior=“automatic” and your Screen needs to have headerTranslucent: true just like @WoLewicki said.

<Stack.Screen
  name="Example"
  component={Example}
  options={() => ({
  headerLargeTitle: true,
  headerTranslucent: true,
 })}
/>

Example.tsx

<ScrollView contentInsetAdjustmentBehavior="automatic" >
 ...
</ScrollView>
2reactions
ArekChrcommented, Jun 16, 2020

With transculent true there is no issue but this isn’t perfect workaround, transculent header brokes another behavior

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected jump while changing position from absolute to ...
So the absolutely positioned elements can scroll off screen (to some extent) before scroll handlers are notified of a new scroll position. The ......
Read more >
Using Position Absolute Inside A Scrolling Overflow Container
Ben Nadel looks at the way absolutely positioned elements behave inside an "overflow: auto" viewport. And, how to wrap the content in order ......
Read more >
Content Jumping (and How To Avoid It) | CSS-Tricks
If the content ends up making the element taller, it can still do that, which isn't great, but it's slightly better than doing...
Read more >
How to make absolute positioned elements overlap their ...
This is a good technique, however the downfall is that if the container is scrollable, the absolutely positioned item will not scroll with...
Read more >
Advanced layouts with absolute and fixed positioning
Absolutely positioned elements are removed entirely from the document flow. That means they have no effect at all on their parent element or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found