Skip to content

Commit f20bb76

Browse files
committed
Reduce swipe action updates
1 parent f3ebdcb commit f20bb76

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,12 @@ public struct MessageListView<Factory: ViewFactory>: View, KeyboardReadable {
319319
coordinateSpace: .global
320320
)
321321
.onChanged { value in
322+
guard abs(value.translation.width) > abs(value.translation.height) else { return }
323+
guard value.translation.width != messageListSwipe?.horizontalOffset else { return }
322324
messageListSwipe = MessageListSwipe(startLocation: value.startLocation, horizontalOffset: value.translation.width)
323325
}
324326
.onEnded { value in
327+
guard let offset = messageListSwipe?.horizontalOffset, offset != 0 else { return }
325328
messageListSwipe = MessageListSwipe(startLocation: value.startLocation, horizontalOffset: 0)
326329
}
327330
)

0 commit comments

Comments
 (0)