Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b1b6053

Browse files
authored
Merge pull request yuyakaido#247 from yuyakaido/issue/237
Disable scroll when empty to avoid invoking onCardDragging
2 parents b5ebf64 + 11cb8fb commit b1b6053

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎cardstackview/src/main/java/com/yuyakaido/android/cardstackview/CardStackLayoutManager.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public boolean canScrollVertically() {
6868

6969
@Override
7070
public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State s) {
71+
if (state.topPosition == getItemCount()) {
72+
return 0;
73+
}
74+
7175
switch (state.status) {
7276
case Idle:
7377
if (setting.swipeableMethod.canSwipeManually()) {
@@ -106,11 +110,16 @@ public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, Recycler
106110
case ManualSwipeAnimated:
107111
break;
108112
}
113+
109114
return 0;
110115
}
111116

112117
@Override
113118
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State s) {
119+
if (state.topPosition == getItemCount()) {
120+
return 0;
121+
}
122+
114123
switch (state.status) {
115124
case Idle:
116125
if (setting.swipeableMethod.canSwipeManually()) {

0 commit comments

Comments
 (0)