Browse Source

enhance: scroll up to reserve more space for editor

Tienson Qin 8 months ago
parent
commit
fc2b95050f

+ 4 - 0
src/main/frontend/mobile/core.cljs

@@ -89,3 +89,7 @@
 (defn keyboard-hide
   []
   (.hide Keyboard))
+
+(defn keyboard-show
+  []
+  (.show Keyboard))

+ 2 - 0
src/main/frontend/mobile/mobile_bar.cljs

@@ -83,6 +83,8 @@
           text' (if (and c (not= c " "))
                   (str " " text)
                   text)]
+      ;; (util/scroll-editor-cursor input :to-vw-one-quarter? true)
+      ;; (.focus input)
       (commands/simple-insert! parent-id text' opts))))
 
 (defn commands

+ 4 - 4
src/main/frontend/util.cljc

@@ -1284,8 +1284,8 @@
              ;; mobile toolbar height: 40px
              scroll      (- cursor-y (- vw-height (+ @keyboard-height (+ 40 4))))]
          (cond
-           (and to-vw-one-quarter? (> cursor-y (* vw-height 0.4)))
-           (set! (.-scrollTop main-node) (+ scroll-top' (- cursor-y (/ vw-height 4))))
+           (and to-vw-one-quarter? (> cursor-y (* vw-height 0.2)))
+           (set! (.-scrollTop main-node) (- (+ scroll-top' cursor-y) 130))
 
            (and (< cursor-y (+ header-height offset-height 4)) ;; 4 is top+bottom padding for per line
                 (>= cursor-y header-height))
@@ -1298,7 +1298,7 @@
              (set! (.-scrollTop main-node) (- scroll-top' (/ vw-height 4))))
 
            (> scroll 0)
-           (set! (.-scrollTop main-node) (+ scroll-top' scroll))
+           (set! (.-scrollTop main-node) (+ scroll-top' scroll 32))
 
            :else
            nil)))))
@@ -1396,7 +1396,7 @@
    (def JS_ROOT
      (when-not node-test?
        (if (or (= js/location.protocol "file:")
-             (string/starts-with? js/location.host "localhost"))
+               (string/starts-with? js/location.host "localhost"))
          "./js"
          "./static/js"))))