Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable gesture on query table and logbook #5784

Merged
merged 5 commits into from Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions ios/App/App/capacitor.config.json
Expand Up @@ -17,9 +17,5 @@
},
"ios": {
"scheme": "Logseq"
},
"server": {
"url": "http://192.168.1.59:3001",
"cleartext": true
}
}
31 changes: 21 additions & 10 deletions src/main/frontend/handler/block.cljs
Expand Up @@ -150,22 +150,33 @@
(def *swipe (atom nil))
(def *touch-start (atom nil))

(defn- target-disable-swipe?
[target]
(let [user-defined-tags (get-in (state/get-config)
[:mobile :gestures/disabled-in-block-with-tags])]
(or (.closest target ".dsl-query")
(.closest target ".drawer")
(some #(.closest target (util/format "[data-refs-self*=%s]" %))
user-defined-tags))))

(defn on-touch-start
[event uuid]
(let [input (state/get-input)
(let [target (.-target event)
input (state/get-input)
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 (not= selection-type "Range")
(when-let [touches (.-targetTouches event)]
(when (= (.-length touches) 1)
(let [touch (aget touches 0)
x (.-clientX touch)
y (.-clientY touch)]
(reset! *swipe {:x0 x :y0 y :xi x :yi y :tx x :ty y :direction nil})))))))
(when-not (target-disable-swipe? target)
(when (not= selection-type "Range")
(when-let [touches (.-targetTouches event)]
(when (= (.-length touches) 1)
(let [touch (aget touches 0)
x (.-clientX touch)
y (.-clientY touch)]
(reset! *swipe {:x0 x :y0 y :xi x :yi y :tx x :ty y :direction nil}))))))))

(defn on-touch-move
[event block uuid edit? *show-left-menu? *show-right-menu?]
Expand Down Expand Up @@ -197,8 +208,8 @@
(let [{:keys [x0 y0]} @*swipe
dx (- tx x0)
dy (- ty y0)]
(when (and (< (. js/Math abs dy) 20)
(> (. js/Math abs dx) 10))
(when (and (< (. js/Math abs dy) 30)
(> (. js/Math abs dx) 30))
(let [left (gdom/getElement (str "block-left-menu-" uuid))
right (gdom/getElement (str "block-right-menu-" uuid))]

Expand Down
5 changes: 5 additions & 0 deletions templates/config.edn
Expand Up @@ -223,6 +223,11 @@
;; :mobile/photo
;; {:allow-editing? true}

;; Mobile features options
;; Gestures
;; :mobile
;; {:gestures/disabled-in-block-with-tags ["kanban"]}

;; Extra CodeMirror options
;; :editor/extra-codemirror-options {:keyMap "emacs" :lineWrapping true}

Expand Down