enhance(mobile): make editing always in viewport when be close to bottom

pull/3547/head
charlie 2021-12-22 16:41:37 +08:00
parent a04ab8e271
commit 672f181a92
2 changed files with 6 additions and 5 deletions

View File

@ -21,9 +21,9 @@
(when-let [element (gdom/getElement id)] (when-let [element (gdom/getElement id)]
(.focus element) (.focus element)
(when (and (util/mobile?) (when (or (mobile-util/is-native-platform?)
(not (mobile-util/native-ios?))) (util/mobile?))
(js/setTimeout #(util/make-el-into-viewport element 60) 64)))) (js/setTimeout #(util/make-el-into-viewport element 60) 80))))
state) state)
(defn did-remount! (defn did-remount!

View File

@ -1491,10 +1491,11 @@
#?(:cljs #?(:cljs
(defn make-el-into-viewport (defn make-el-into-viewport
[^js/HTMLElement el offset] [^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))] target-bottom (.-bottom (.getBoundingClientRect el))]
(when (> (+ target-bottom (or (safe-parse-int offset) 0)) (when (> (+ target-bottom (or (safe-parse-int offset) 0))
wrap-height) viewport-height)
(.scrollIntoView el #js {:block "center" :behavior "smooth"}))))) (.scrollIntoView el #js {:block "center" :behavior "smooth"})))))
#?(:cljs #?(:cljs