From 6759797b8a4cf356952c4c528ce731ce141ba26c Mon Sep 17 00:00:00 2001 From: Alex Iribarren Date: Mon, 20 May 2019 14:44:05 +0200 Subject: [PATCH] Added stickyHeaderOffset --- src/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 8787b6f..b77f6e0 100644 --- a/src/index.js +++ b/src/index.js @@ -40,6 +40,7 @@ const IPropTypes = { renderScrollComponent: func, renderStickyHeader: func, stickyHeaderHeight: number, + stickyHeaderOffset: number, contentContainerStyle: ViewPropTypes.style, outputScaleValue: number } @@ -87,6 +88,7 @@ class ParallaxScrollView extends Component { renderForeground, renderParallaxHeader, renderScrollComponent, + stickyHeaderOffset, renderStickyHeader, stickyHeaderHeight, style, @@ -122,6 +124,7 @@ class ParallaxScrollView extends Component { stickyHeaderHeight, backgroundColor, renderFixedHeader, + stickyHeaderOffset, renderStickyHeader }) const scrollElement = renderScrollComponent(scrollViewProps) @@ -367,6 +370,7 @@ class ParallaxScrollView extends Component { stickyHeaderHeight, backgroundColor, renderFixedHeader, + stickyHeaderOffset, renderStickyHeader }) { const { viewWidth } = this.state @@ -400,8 +404,8 @@ class ParallaxScrollView extends Component { transform: [ { translateY: interpolate(scrollY, { - inputRange: [0, p], - outputRange: [stickyHeaderHeight, 0], + inputRange: [0, p + (stickyHeaderOffset != null ? stickyHeaderOffset : 0)], + outputRange: [(stickyHeaderOffset != null ? parallaxHeaderHeight : stickyHeaderHeight), 0], extrapolate: 'clamp' }) } @@ -435,6 +439,7 @@ ParallaxScrollView.defaultProps = { renderParallaxHeader: renderEmpty, // Deprecated (will be removed in 0.18.0) renderForeground: null, stickyHeaderHeight: 0, + stickyHeaderOffset: null, contentContainerStyle: null, outputScaleValue: 5 }