mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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:
committed by
Facebook GitHub Bot
parent
3cffe352b5
commit
2feca00797
+5
-2
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user