mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
ScrollView, HorizontalScrollView: support null contentOffset
Summary: According to the Flow types, `contentOffset` is nullable. Support that. Changelog: [Internal] Fix to (1) support null contentOffset in ScrollView and HorizontalScrollView, added on Android after the last release. (2) Correctly add support for contentOffset in ScrollView (I missed that when adding it to HorizontalScrollView in the previous diff). Reviewed By: alsun2001 Differential Revision: D21243028 fbshipit-source-id: ebef9a9054a3e4dd88556739e836b7ece48fda12
This commit is contained in:
committed by
Facebook GitHub Bot
parent
aad99607de
commit
30cc158a87
+5
-3
@@ -303,8 +303,10 @@ public class ReactHorizontalScrollViewManager extends ViewGroupManager<ReactHori
|
||||
|
||||
@ReactProp(name = "contentOffset")
|
||||
public void setContentOffset(ReactHorizontalScrollView view, ReadableMap value) {
|
||||
double x = value.getDouble("x");
|
||||
double y = value.getDouble("y");
|
||||
view.reactScrollTo((int) PixelUtil.toPixelFromDIP(x), (int) PixelUtil.toPixelFromDIP(y));
|
||||
if (value != null) {
|
||||
double x = value.getDouble("x");
|
||||
double y = value.getDouble("y");
|
||||
view.reactScrollTo((int) PixelUtil.toPixelFromDIP(x), (int) PixelUtil.toPixelFromDIP(y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -13,6 +13,7 @@ import android.view.View;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.RetryableMountingLayerException;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
import com.facebook.react.module.annotations.ReactModule;
|
||||
@@ -304,6 +305,15 @@ public class ReactScrollViewManager extends ViewGroupManager<ReactScrollView>
|
||||
}
|
||||
}
|
||||
|
||||
@ReactProp(name = "contentOffset")
|
||||
public void setContentOffset(ReactScrollView view, ReadableMap value) {
|
||||
if (value != null) {
|
||||
double x = value.getDouble("x");
|
||||
double y = value.getDouble("y");
|
||||
view.reactScrollTo((int) PixelUtil.toPixelFromDIP(x), (int) PixelUtil.toPixelFromDIP(y));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object updateState(
|
||||
ReactScrollView view, ReactStylesDiffMap props, @Nullable StateWrapper stateWrapper) {
|
||||
|
||||
Reference in New Issue
Block a user