@@ -137,12 +137,12 @@ class SwipeLayout @JvmOverloads constructor(
137
137
return activeMenu == rightMenu && openState and FLAG_IS_OPENED == FLAG_IS_OPENED
138
138
}
139
139
140
- fun isStartMenuOpened ():Boolean {
140
+ fun isStartMenuOpened (): Boolean {
141
141
return if (isLayoutRTL()) isRightMenuOpened() else isLeftMenuOpened()
142
142
}
143
143
144
144
fun isEndMenuOpened (): Boolean {
145
- return if (isLayoutRTL()) isLeftMenuOpened() else isRightMenuOpened()
145
+ return if (isLayoutRTL()) isLeftMenuOpened() else isRightMenuOpened()
146
146
}
147
147
148
148
fun openLeftMenu (animate : Boolean = true) {
@@ -265,9 +265,11 @@ class SwipeLayout @JvmOverloads constructor(
265
265
val dx = ev.x.toInt() - downX
266
266
val dy = ev.y.toInt() - downY
267
267
268
+ val isLeftDragging = dx < - touchSlop && abs(dx) > abs(dy)
269
+ val isRightDragging = dx > touchSlop && dx > abs(dy)
268
270
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
271
273
272
274
if (openState and FLAG_IS_OPENED == FLAG_IS_OPENED
273
275
|| openState and FLAG_IS_OPENING == FLAG_IS_OPENING
@@ -278,10 +280,10 @@ class SwipeLayout @JvmOverloads constructor(
278
280
isDragging = isLeftDragging || isRightDragging
279
281
}
280
282
} else {
281
- if (isRightDragging) {
283
+ if (isRightDragging && canDragRight ) {
282
284
activeMenu = leftMenu
283
285
isDragging = activeMenu != null
284
- } else if (isLeftDragging) {
286
+ } else if (isLeftDragging && canDragLeft ) {
285
287
activeMenu = rightMenu
286
288
isDragging = activeMenu != null
287
289
}
0 commit comments