Skip to content

Commit

Permalink
Add snapToAlignment to ReactScrollViewManager
Browse files Browse the repository at this point in the history
Summary:
This diff adds the new snapToAlignment into ReactScrollViewManager
changelog: [Android][Added] Implement snapToAlignment into ReactScrollViewManager

Reviewed By: JoshuaGross

Differential Revision: D31182787

fbshipit-source-id: 8049ceb462461a11f184dbc1b40ca8079a3e8b60
  • Loading branch information
mdvacca authored and facebook-github-bot committed Sep 29, 2021
1 parent d97a1a5 commit c6e5640
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

package com.facebook.react.views.scroll;

import static com.facebook.react.views.scroll.ReactScrollViewHelper.SNAP_ALIGNMENT_DISABLED;

import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
Expand Down Expand Up @@ -92,6 +94,7 @@ public class ReactScrollView extends ScrollView
private @Nullable List<Integer> mSnapOffsets;
private boolean mSnapToStart = true;
private boolean mSnapToEnd = true;
private int mSnapToAlignment = SNAP_ALIGNMENT_DISABLED;
private @Nullable View mContentView;
private ReactViewBackgroundManager mReactBackgroundManager;
private int pendingContentOffsetX = UNSET_CONTENT_OFFSET;
Expand Down Expand Up @@ -218,6 +221,10 @@ public void setSnapToEnd(boolean snapToEnd) {
mSnapToEnd = snapToEnd;
}

public void setSnapToAlignment(int snapToAlignment) {
mSnapToAlignment = snapToAlignment;
}

public void flashScrollIndicators() {
awakenScrollBars();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public void setSnapToOffsets(ReactScrollView view, @Nullable ReadableArray snapT
view.setSnapOffsets(offsets);
}

@ReactProp(name = "snapToAlignment")
public void setSnapToAlignment(ReactScrollView view, String alignment) {
view.setSnapToAlignment(ReactScrollViewHelper.parseSnapToAlignment(alignment));
}

@ReactProp(name = "snapToStart")
public void setSnapToStart(ReactScrollView view, boolean snapToStart) {
view.setSnapToStart(snapToStart);
Expand Down

0 comments on commit c6e5640

Please sign in to comment.