Skip to content

Commit

Permalink
tempory fix for wrong positions of custom context menu
Browse files Browse the repository at this point in the history
which is caused by the bump of rum too.
  • Loading branch information
tiensonqin committed Apr 2, 2022
1 parent b7348af commit 3758a9e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
11 changes: 7 additions & 4 deletions src/main/frontend/components/content.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,13 @@

(rum/use-effect!
(fn []
(let [^js el (rum/deref *el-ref)
{:keys [x y]} (util/calc-delta-rect-offset el js/document.documentElement)]
(set! (.. el -style -transform)
(str "translate3d(" (if (neg? x) x 0) "px," (if (neg? y) (- y 10) 0) "px" ",0)")))
(js/setTimeout
(fn []
(let [^js el (rum/deref *el-ref)
{:keys [x y]} (util/calc-delta-rect-offset el js/document.documentElement)]
(set! (.. el -style -transform)
(str "translate3d(" (if (neg? x) x 0) "px," (if (neg? y) (- y 10) 0) "px" ",0)"))))
10)
#())
[])

Expand Down
6 changes: 4 additions & 2 deletions src/main/frontend/components/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

#custom-context-menu {
@apply rounded-md shadow-lg transition ease-out duration-100 transform
opacity-100 scale-100 absolute;
opacity-100 scale-100 absolute overflow-y-auto;

max-height: calc(100vh - 100px) !important;;
overflow-y: scroll;
z-index: calc(var(--ls-z-index-level-1) + 1);
}
}
13 changes: 9 additions & 4 deletions src/main/frontend/handler/common.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,15 @@
client-y (gobj/get e "clientY")
scroll-y (util/cur-doc-top)]
(state/show-custom-context-menu! context-menu-content)
(when-let [context-menu (d/by-id "custom-context-menu")]
(d/set-style! context-menu
:left (str client-x "px")
:top (str (+ scroll-y client-y) "px")))))

;; FIXME: use setTimeout here because rum renders lazily.
(js/setTimeout
(fn []
(when-let [context-menu (d/by-id "custom-context-menu")]
(d/set-style! context-menu
:left (str client-x "px")
:top (str (+ scroll-y client-y) "px"))))
10)))

(defn parse-config
"Parse configuration from file `content` such as from config.edn."
Expand Down

0 comments on commit 3758a9e

Please sign in to comment.