Quellcode durchsuchen

don't snap the table view cells back to the bottom if the user swiped down the keyboard and scrolling is still ongoing

cyberta vor 4 Jahren
Ursprung
Commit
fc64a88d2b
1 geänderte Dateien mit 8 neuen und 7 gelöschten Zeilen
  1. 8 7
      deltachat-ios/Chat/ChatViewController.swift

+ 8 - 7
deltachat-ios/Chat/ChatViewController.swift

@@ -279,13 +279,14 @@ class ChatViewController: UITableViewController {
         let keyboardRectangle = keyboardFrame.cgRectValue
         let keyboardHeight = keyboardRectangle.height
         tableView.contentInset = UIEdgeInsets(top: self.getTopInsetHeight(), left: 0, bottom: keyboardHeight, right: 0)
-        if self.isLastRowVisible() {
-            DispatchQueue.main.async { [weak self] in
-                if self?.messageInputBar.keyboardHeight ?? 0 > 0 {
-                    self?.scrollToBottom(animated: true)
-                } else { // inputbar height increased, probably because of draft area changes
-                    self?.scrollToBottom(animated: false)
-                }
+        // adapt the scroll position if the table view is not already moving and if the last row is visible
+        if self.isLastRowVisible() && !tableView.isDragging && !tableView.isDecelerating {
+            if self.messageInputBar.keyboardHeight > 0 {
+                logger.debug("scrolling keyboardWillShow - animated: true")
+                self.scrollToBottom(animated: true)
+            } else { // inputbar height increased, probably because of draft area changes
+                logger.debug("scrolling keyboardWillShow - animated: false")
+                self.scrollToBottom(animated: false)
             }
         }
     }