mirror of https://github.com/logseq/logseq
enhance(mobile): make editing always in viewport when be close to bottom
parent
a04ab8e271
commit
672f181a92
|
@ -21,9 +21,9 @@
|
|||
|
||||
(when-let [element (gdom/getElement id)]
|
||||
(.focus element)
|
||||
(when (and (util/mobile?)
|
||||
(not (mobile-util/native-ios?)))
|
||||
(js/setTimeout #(util/make-el-into-viewport element 60) 64))))
|
||||
(when (or (mobile-util/is-native-platform?)
|
||||
(util/mobile?))
|
||||
(js/setTimeout #(util/make-el-into-viewport element 60) 80))))
|
||||
state)
|
||||
|
||||
(defn did-remount!
|
||||
|
|
|
@ -1491,10 +1491,11 @@
|
|||
#?(:cljs
|
||||
(defn make-el-into-viewport
|
||||
[^js/HTMLElement el offset]
|
||||
(let [wrap-height (.-clientHeight js/document.documentElement)
|
||||
(let [viewport-height (or (.-height js/window.visualViewport)
|
||||
(.-clientHeight js/document.documentElement))
|
||||
target-bottom (.-bottom (.getBoundingClientRect el))]
|
||||
(when (> (+ target-bottom (or (safe-parse-int offset) 0))
|
||||
wrap-height)
|
||||
viewport-height)
|
||||
(.scrollIntoView el #js {:block "center" :behavior "smooth"})))))
|
||||
|
||||
#?(:cljs
|
||||
|
|
Loading…
Reference in New Issue