Skip to content

Commit

Permalink
Remove the effect of swipeFlags on touch on menus.
Browse files Browse the repository at this point in the history
  • Loading branch information
aitsuki committed Jun 7, 2022
1 parent e2ce2f3 commit 6cbe597
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

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

Expand Down Expand Up @@ -50,7 +50,7 @@ dependencyResolutionManagement {

```groovy
dependencies {
implementation 'com.github.aitsuki:SwipeMenuRecyclerView:2.1.3'
implementation 'com.github.aitsuki:SwipeMenuRecyclerView:2.1.5'
}
```

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dependencyResolutionManagement {

```groovy
dependencies {
implementation 'com.github.aitsuki:SwipeMenuRecyclerView:2.1.3'
implementation 'com.github.aitsuki:SwipeMenuRecyclerView:2.1.5'
}
```

Expand Down
14 changes: 8 additions & 6 deletions library/src/main/java/com/aitsuki/swipe/SwipeLayout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ class SwipeLayout @JvmOverloads constructor(
return activeMenu == rightMenu && openState and FLAG_IS_OPENED == FLAG_IS_OPENED
}

fun isStartMenuOpened():Boolean {
fun isStartMenuOpened(): Boolean {
return if (isLayoutRTL()) isRightMenuOpened() else isLeftMenuOpened()
}

fun isEndMenuOpened(): Boolean {
return if (isLayoutRTL()) isLeftMenuOpened() else isRightMenuOpened()
return if (isLayoutRTL()) isLeftMenuOpened() else isRightMenuOpened()
}

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

val isLeftDragging = dx < -touchSlop && abs(dx) > abs(dy)
val isRightDragging = dx > touchSlop && dx > abs(dy)
val direction = getAbsoluteDirection(swipeFlags)
val isLeftDragging = dx < -touchSlop && (direction and LEFT) != 0 && abs(dx) > abs(dy)
val isRightDragging = dx > touchSlop && (direction and RIGHT) != 0 && dx > abs(dy)
val canDragLeft = (direction and LEFT) != 0
val canDragRight = (direction and RIGHT) != 0

if (openState and FLAG_IS_OPENED == FLAG_IS_OPENED
|| openState and FLAG_IS_OPENING == FLAG_IS_OPENING
Expand All @@ -278,10 +280,10 @@ class SwipeLayout @JvmOverloads constructor(
isDragging = isLeftDragging || isRightDragging
}
} else {
if (isRightDragging) {
if (isRightDragging && canDragRight) {
activeMenu = leftMenu
isDragging = activeMenu != null
} else if (isLeftDragging) {
} else if (isLeftDragging && canDragLeft) {
activeMenu = rightMenu
isDragging = activeMenu != null
}
Expand Down

0 comments on commit 6cbe597

Please sign in to comment.