Toggle ScrollView.snapToAlignment behavior using ReactFeatureFlag.enableScrollViewSnapToAlignmentProp

Summary:
This diff enables/disables ScrollView.snapToAlignment behavior using ReactFeatureFlag.enableScrollViewSnapToAlignmentProp

changelog: [internal] internal

Reviewed By: motiz88

Differential Revision: D31308300

fbshipit-source-id: 26c01a342cac822f21d83e3474b529bea154aba6
This commit is contained in:
David Vacca
2021-09-30 10:17:07 -07:00
committed by Facebook GitHub Bot
parent 3cffe352b5
commit 2feca00797
2 changed files with 10 additions and 4 deletions
@@ -7,6 +7,7 @@
package com.facebook.react.views.scroll;
import static com.facebook.react.config.ReactFeatureFlags.enableScrollViewSnapToAlignmentProp;
import static com.facebook.react.views.scroll.ReactScrollViewHelper.SNAP_ALIGNMENT_CENTER;
import static com.facebook.react.views.scroll.ReactScrollViewHelper.SNAP_ALIGNMENT_DISABLED;
import static com.facebook.react.views.scroll.ReactScrollViewHelper.SNAP_ALIGNMENT_END;
@@ -916,7 +917,9 @@ public class ReactHorizontalScrollView extends HorizontalScrollView
}
// pagingEnabled only allows snapping one interval at a time
if (mSnapInterval == 0 && mSnapOffsets == null && mSnapToAlignment == SNAP_ALIGNMENT_DISABLED) {
if (mSnapInterval == 0
&& mSnapOffsets == null
&& (!enableScrollViewSnapToAlignmentProp || mSnapToAlignment == SNAP_ALIGNMENT_DISABLED)) {
smoothScrollAndSnap(velocityX);
return;
}
@@ -959,7 +962,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView
}
}
}
} else if (mSnapToAlignment != SNAP_ALIGNMENT_DISABLED) {
} else if (enableScrollViewSnapToAlignmentProp && mSnapToAlignment != SNAP_ALIGNMENT_DISABLED) {
if (mSnapInterval > 0) {
double ratio = (double) targetOffset / mSnapInterval;
smallerOffset =
@@ -7,6 +7,7 @@
package com.facebook.react.views.scroll;
import static com.facebook.react.config.ReactFeatureFlags.enableScrollViewSnapToAlignmentProp;
import static com.facebook.react.views.scroll.ReactScrollViewHelper.SNAP_ALIGNMENT_CENTER;
import static com.facebook.react.views.scroll.ReactScrollViewHelper.SNAP_ALIGNMENT_DISABLED;
import static com.facebook.react.views.scroll.ReactScrollViewHelper.SNAP_ALIGNMENT_END;
@@ -704,7 +705,9 @@ public class ReactScrollView extends ScrollView
}
// pagingEnabled only allows snapping one interval at a time
if (mSnapInterval == 0 && mSnapOffsets == null && mSnapToAlignment == SNAP_ALIGNMENT_DISABLED) {
if (mSnapInterval == 0
&& mSnapOffsets == null
&& (!enableScrollViewSnapToAlignmentProp || mSnapToAlignment == SNAP_ALIGNMENT_DISABLED)) {
smoothScrollAndSnap(velocityY);
return;
}
@@ -742,7 +745,7 @@ public class ReactScrollView extends ScrollView
}
}
} else if (mSnapToAlignment != SNAP_ALIGNMENT_DISABLED) {
} else if (enableScrollViewSnapToAlignmentProp && mSnapToAlignment != SNAP_ALIGNMENT_DISABLED) {
if (mSnapInterval > 0) {
double ratio = (double) targetOffset / mSnapInterval;
smallerOffset =