Browse Source

Take scaled touch slop into account when calculating if screen can collapse (#799)

Guy Carmeli 7 years ago
parent
commit
1b127f70a9

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/views/collapsingToolbar/CollapseCalculator.java View File

@@ -158,13 +158,13 @@ public class CollapseCalculator {
158 158
     private boolean calculateCanCollapse(float currentTopBarTranslation, float finalExpendedTranslation, float finalCollapsedTranslation) {
159 159
         return currentTopBarTranslation > finalCollapsedTranslation &&
160 160
                currentTopBarTranslation <= finalExpendedTranslation &&
161
-               (scrollView.getScrollY() == 0 || (collapseBehaviour instanceof TitleBarHideOnScrollBehaviour || collapseBehaviour instanceof CollapseTitleBarBehaviour));
161
+               (scrollView.getScrollY() <= scaledTouchSlop || (collapseBehaviour instanceof TitleBarHideOnScrollBehaviour || collapseBehaviour instanceof CollapseTitleBarBehaviour));
162 162
     }
163 163
 
164 164
     private boolean calculateCanExpend(float currentTopBarTranslation, float finalExpendedTranslation, float finalCollapsedTranslation) {
165 165
         return currentTopBarTranslation >= finalCollapsedTranslation &&
166 166
                currentTopBarTranslation < finalExpendedTranslation &&
167
-               (scrollView.getScrollY() == 0 || (collapseBehaviour instanceof TitleBarHideOnScrollBehaviour || collapseBehaviour instanceof CollapseTitleBarBehaviour));
167
+               (scrollView.getScrollY() <= scaledTouchSlop || (collapseBehaviour instanceof TitleBarHideOnScrollBehaviour || collapseBehaviour instanceof CollapseTitleBarBehaviour));
168 168
     }
169 169
 
170 170
     private boolean isCollapsedAndScrollingDown(Direction direction) {