Skip to content

Commit 6cbe597

Browse files
committed
Remove the effect of swipeFlags on touch on menus.
1 parent e2ce2f3 commit 6cbe597

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

README.en.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
SwipeMenuRecyclerView is a lightweight sliding menu library,it can be use in the list or on its own.
44

5-
- Support multiple styles of menus (Classic, Overlay, Parallax), and easily customize your new styles.
5+
- Support multiple styles of menus (Classic, Overlay, Parallax), and easily customize your own style.
66
- Support long menus, you can also slide on menu button.
77
- Easily build in layout editor, as simple as build a TextView.
88

@@ -50,7 +50,7 @@ dependencyResolutionManagement {
5050

5151
```groovy
5252
dependencies {
53-
implementation 'com.github.aitsuki:SwipeMenuRecyclerView:2.1.3'
53+
implementation 'com.github.aitsuki:SwipeMenuRecyclerView:2.1.5'
5454
}
5555
```
5656

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ dependencyResolutionManagement {
5252

5353
```groovy
5454
dependencies {
55-
implementation 'com.github.aitsuki:SwipeMenuRecyclerView:2.1.3'
55+
implementation 'com.github.aitsuki:SwipeMenuRecyclerView:2.1.5'
5656
}
5757
```
5858

library/src/main/java/com/aitsuki/swipe/SwipeLayout.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ class SwipeLayout @JvmOverloads constructor(
137137
return activeMenu == rightMenu && openState and FLAG_IS_OPENED == FLAG_IS_OPENED
138138
}
139139

140-
fun isStartMenuOpened():Boolean {
140+
fun isStartMenuOpened(): Boolean {
141141
return if (isLayoutRTL()) isRightMenuOpened() else isLeftMenuOpened()
142142
}
143143

144144
fun isEndMenuOpened(): Boolean {
145-
return if (isLayoutRTL()) isLeftMenuOpened() else isRightMenuOpened()
145+
return if (isLayoutRTL()) isLeftMenuOpened() else isRightMenuOpened()
146146
}
147147

148148
fun openLeftMenu(animate: Boolean = true) {
@@ -265,9 +265,11 @@ class SwipeLayout @JvmOverloads constructor(
265265
val dx = ev.x.toInt() - downX
266266
val dy = ev.y.toInt() - downY
267267

268+
val isLeftDragging = dx < -touchSlop && abs(dx) > abs(dy)
269+
val isRightDragging = dx > touchSlop && dx > abs(dy)
268270
val direction = getAbsoluteDirection(swipeFlags)
269-
val isLeftDragging = dx < -touchSlop && (direction and LEFT) != 0 && abs(dx) > abs(dy)
270-
val isRightDragging = dx > touchSlop && (direction and RIGHT) != 0 && dx > abs(dy)
271+
val canDragLeft = (direction and LEFT) != 0
272+
val canDragRight = (direction and RIGHT) != 0
271273

272274
if (openState and FLAG_IS_OPENED == FLAG_IS_OPENED
273275
|| openState and FLAG_IS_OPENING == FLAG_IS_OPENING
@@ -278,10 +280,10 @@ class SwipeLayout @JvmOverloads constructor(
278280
isDragging = isLeftDragging || isRightDragging
279281
}
280282
} else {
281-
if (isRightDragging) {
283+
if (isRightDragging && canDragRight) {
282284
activeMenu = leftMenu
283285
isDragging = activeMenu != null
284-
} else if (isLeftDragging) {
286+
} else if (isLeftDragging && canDragLeft) {
285287
activeMenu = rightMenu
286288
isDragging = activeMenu != null
287289
}

0 commit comments

Comments
 (0)