resolve conflicts between select and swipe on non-editing mode

Also, fix issue that it is hard to move caret on editing mode
pull/5557/head^2
llcc 2022-06-06 15:55:56 +08:00 committed by Tienson Qin
parent 13cc487592
commit cd6e2ca051
1 changed files with 71 additions and 66 deletions

View File

@ -148,16 +148,18 @@
(state/exit-editing-and-set-selected-blocks! blocks))))
(def *swipe (atom nil))
(def *touch-start (atom nil))
(defn on-touch-start
[event uuid]
(let [input (state/get-input)
input-id (state/get-edit-input-id)]
input-id (state/get-edit-input-id)
selection-type (.-type (.getSelection js/document))]
(reset! *touch-start (js/Date.now))
(when-not (and input
(string/ends-with? input-id (str uuid)))
(state/clear-edit!))
(when (= (util/get-selection-start input)
(util/get-selection-end input))
(when (not= selection-type "Range")
(when-let [touches (.-targetTouches event)]
(when (= (.-length touches) 1)
(let [touch (aget touches 0)
@ -168,6 +170,9 @@
(defn on-touch-move
[event block uuid edit? *show-left-menu? *show-right-menu?]
(when-let [touches (.-targetTouches event)]
(let [selection-type (.-type (.getSelection js/document))]
(when-not (= selection-type "Range")
(when (< (- (js/Date.now) @*touch-start) 600)
(when (and (= (.-length touches) 1) @*swipe)
(let [{:keys [x0 xi direction]} @*swipe
touch (aget touches 0)
@ -235,7 +240,7 @@
(set! (.. more -style -opacity) "100%")
(set! (.. more -style -opacity) "30%"))))))
:else
nil))))))))
nil)))))))))))
(defn on-touch-end
[_event block uuid *show-left-menu? *show-right-menu?]