CollapsingHeader example with scrolling content
See original GitHub issueIn the CollapsingHeader example, the main body (below the header) does not scroll when the content goes off screen. The below example is a copy paste of the example with extra View
content. Only 4 boxes are show.
I’ve tried experimenting with a ScrollView, however it either causes the header to scroll off screen (when a parent of Interactable) or does nothing (a child of Interactable).
If Interactable is wrapped in a ScrollView, it doesn’t seem to pick up all of the scroll events (header scales sometimes, sometimes not), but I do see the content.
Is there a way to achieve this?
import React, { Component } from 'react';
import { StyleSheet, ScrollView, View, Animated } from 'react-native';
import Interactable from 'react-native-interactable';
export default class CollapsingHeader extends Component {
constructor(props) {
super(props);
this._deltaY = new Animated.Value(0);
}
render() {
return (
<View style={styles.container}>
<View style={{backgroundColor: 'red', height: 250, alignItems: 'center'}}>
<Animated.View style={{
transform: [
{
translateY: this._deltaY.interpolate({
inputRange: [-150, -150, 0, 0],
outputRange: [-58, -58, 0, 0]
})
},
{
scale: this._deltaY.interpolate({
inputRange: [-150, -150, 0, 0],
outputRange: [0.35, 0.35, 1, 1]
})
}
]
}}>
<View style={{width: 150, height: 150, backgroundColor: 'blue', borderRadius: 75, marginTop: 50}} />
</Animated.View>
</View>
<Interactable.View
verticalOnly={true}
snapPoints={[{y: 0}, {y: -150}]}
boundaries={{top: -150}}
animatedValueY={this._deltaY}>
<View style={{left: 0, right: 0, height: 650, backgroundColor: '#e0e0e0'}}>
<View style={{ backgroundColor: 'grey', height: 100, marginVertical: 8 }} />
<View style={{ backgroundColor: 'grey', height: 100, marginVertical: 8 }} />
<View style={{ backgroundColor: 'grey', height: 100, marginVertical: 8 }} />
<View style={{ backgroundColor: 'grey', height: 100, marginVertical: 8 }} />
<View style={{ backgroundColor: 'grey', height: 100, marginVertical: 8 }} />
<View style={{ backgroundColor: 'grey', height: 100, marginVertical: 8 }} />
<View style={{ backgroundColor: 'grey', height: 100, marginVertical: 8 }} />
<View style={{ backgroundColor: 'grey', height: 100, marginVertical: 8 }} />
</View>
</Interactable.View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
}
});
Issue Analytics
- State:
- Created 6 years ago
- Reactions:15
- Comments:46 (12 by maintainers)
Top Results From Across the Web
How to Create a Simple Collapsing Header with UIScrollView
This blog post will walk you through a simple implementation of a collapsing header in an iOS app using UIKit. The main components...
Read more >How To Create a Simple Collapsing Header Effect - Line25
In this example we'll create a thin header bar along the top of the page, ... To ensure the rest of the page...
Read more >How to Create a Collapsing Header Effect With Pure CSS
If the z-index of the banner is higher than the z-index of the content div, it will scroll over the content div. The...
Read more >Collapsing header webpage with animated content ... - YouTube
Learn how to make collapsing header and how to animate images ... Collapsing header webpage with animated content upon scroll (English).
Read more >SwiftUI 3.0 Collapsable Animated Sticky Header - YouTube
... 7:38 Building Message View 9:15 Collapsing Header Animation Thanks for watching Make sure to like and Subscribe For More Content !!!
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Try this hack, maybe helpful:
Works on both iOS and Android Tested on RN 0.57RC3
TouchableWithoutFeedback
will prioritize scrollView touch events thanInteractable.View
Any updates on this?