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.

CollapsingHeader example with scrolling content

See original GitHub issue

In 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:open
  • Created 6 years ago
  • Reactions:15
  • Comments:46 (12 by maintainers)

github_iconTop GitHub Comments

14reactions
hadimostafapourcommented, Sep 9, 2018

Try this hack, maybe helpful:

Works on both iOS and Android Tested on RN 0.57RC3

TouchableWithoutFeedback will prioritize scrollView touch events than Interactable.View

<ScrollView>
       <TouchableWithoutFeedback>
                <View>{this.props.children}</View>
      </TouchableWithoutFeedback>
</ScrollView>

13reactions
RichardLindhoutcommented, Jun 30, 2017

Any updates on this?

Read more comments on GitHub >

github_iconTop 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 >

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