netguru / sticky-parallax-header

A simple React Native library, enabling the creation of fully customized header for your iOS and Android apps.
https://netguru.github.io/sticky-parallax-header/
MIT License
1.86k stars 190 forks source link

scroll not responsive #212

Closed hotaryuzaki closed 3 years ago

hotaryuzaki commented 3 years ago

scroll not responsive

20210611_100931

renderHeader = () => {
  const { goBack } = this.props.navigation;
  const produk = this.state.productDetail[0];
  const { scroll } = this.state;
  const opacity = scroll.interpolate({
    inputRange: [0, Layout.window.width/1.7+28, Layout.window.width/1.7+56], // SETUP KAPAN PARALAX HEADER MUNCUL
    outputRange: [0, 0, 1],
    extrapolate: 'clamp'
  });

  return (
     <View>
       <View style={[styles.parallaxLeft, { position: 'absolute', paddingHorizontal: 7 }]}>
        <Button transparent rounded style={styles.parallaxBack} onPress={() => goBack()}>
          <Icon.Ionicons
            name="md-arrow-back"
            size={24} color={Colors.colorLevel10}
          />
        </Button>
       </View>

    <Animated.View style={{ backgroundColor: Colors.colorLevel1, opacity }}>
          <View style={styles.parallaxHeader}>
            <View style={styles.parallaxLeft}>
              <Button transparent rounded style={styles.parallaxBack} onPress={() => goBack()}>
                <Icon.Ionicons
                  name="md-arrow-back"
                  size={24} color={Colors.colorLevel10}
                />
              </Button>
            </View>
            <View style={styles.parallaxRight}>
              <Text style={styles.parallaxText}>
                {this.strCutter(produk.product_name, 30)}
              </Text>
            </View>
              </View>
        </Animated.View>
    </View>
  )
}

<StickyParalaxHeader
    header={this.renderHeader()}
    headerHeight={56}
    headerSize={() => {}}
    transparentHeader
    scrollEvent={Animated.event([{ nativeEvent: { contentOffset: { y: scroll } } }])}
>
  <ScrollView>
    <View>
    </View>
    <View>
    </View>
    <View>  
    </View>
  </ScrollView>
</StickyParalaxHeader>
brambang commented 3 years ago

there is solution here, https://github.com/netguru/sticky-parallax-header/pull/182 this fix not merge to master yet.

but i found decelerationRate props is already exist, but why you not put this in readme?? decelerationRate='normal' fix this issue. and i think is best to set 'normal' as default value since 'fast' created an issue

hotaryuzaki commented 3 years ago

there is solution here, #182 this fix not merge to master yet.

but i found decelerationRate props is already exist, but why you not put this in readme?? decelerationRate='normal' fix this issue. and i think is best to set 'normal' as default value since 'fast' created an issue

Thanks it works