From 5c3f19af477f6f5d0a8db2d9ff71f1f76f6f3790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=BB=BA=E5=B3=B0?= Date: Wed, 24 Feb 2021 16:47:58 +0800 Subject: [PATCH 1/2] code style --- src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 8787b6f..4550ebe 100644 --- a/src/index.js +++ b/src/index.js @@ -154,8 +154,8 @@ class ParallaxScrollView extends Component { } /* - * Expose `ScrollView` API so this component is composable with any component that expects a `ScrollView`. - */ + * Expose `ScrollView` API so this component is composable with any component that expects a `ScrollView`. + */ getScrollResponder() { return this.refs[SCROLLVIEW_REF]._component.getScrollResponder() } @@ -173,8 +173,8 @@ class ParallaxScrollView extends Component { } /* - * Private helpers - */ + * Private helpers + */ _onScroll(e) { const { From 9eca0c882bbbae81cc0a7b8cf32e40f2df4dad8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=BB=BA=E5=B3=B0?= Date: Wed, 24 Feb 2021 17:12:57 +0800 Subject: [PATCH 2/2] enable backgroundScrollSpeed === 0 --- src/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 4550ebe..e26757d 100644 --- a/src/index.js +++ b/src/index.js @@ -252,7 +252,7 @@ class ParallaxScrollView extends Component { { translateY: interpolate(scrollY, { inputRange: [0, p], - outputRange: [0, -(p / backgroundScrollSpeed)], + outputRange: [0, backgroundScrollSpeed === 0 ? 0 : -(p / backgroundScrollSpeed)], extrapolateRight: 'extend', extrapolateLeft: 'clamp' }) @@ -371,6 +371,7 @@ class ParallaxScrollView extends Component { }) { const { viewWidth } = this.state const { scrollY } = this + const { backgroundScrollSpeed } = this.props; if (renderStickyHeader || renderFixedHeader) { const p = pivotPoint(parallaxHeaderHeight, stickyHeaderHeight) return ( @@ -401,7 +402,7 @@ class ParallaxScrollView extends Component { { translateY: interpolate(scrollY, { inputRange: [0, p], - outputRange: [stickyHeaderHeight, 0], + outputRange: [backgroundScrollSpeed === 0 ? 0 : stickyHeaderHeight, 0], extrapolate: 'clamp' }) }