Skip to content

Commit

Permalink
Resize pixi app on window resize
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhanshuguptagit committed Aug 25, 2024
1 parent 7da10d1 commit ed9c63a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ p {

#grid-container {
position: relative;
height: 100%;
height: 100vh;
width: 100%;
}

Expand Down
10 changes: 9 additions & 1 deletion src/bean/ui/views/sheet.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,13 @@
(dorun (->> col-widths (reductions +) (map draw-vertical)))
g)))

(defn resize-pixi-app [app]
(let [container (.getElementById js/document "grid-container")
h (.-offsetHeight container)
w (.-offsetWidth container)]
(.resize app w h)
(.resize (:viewport @pixi-app) w h)))

(defn- make-app []
(let [app (new
pixi/Application
Expand All @@ -747,7 +754,8 @@
(.getElementById js/document "grid-container")
(.-view app))
(set! (.-__PIXI_APP__ js/globalThis) app)
(.addEventListener js/window "wheel" #(.preventDefault %1) #js {:passive false})
(.addEventListener (.getElementById js/document "grid-container") "wheel" #(.preventDefault %1) #js {:passive false})
(.addEventListener js/window "resize" #(resize-pixi-app app))
app))

(defn- make-viewport [app]
Expand Down

0 comments on commit ed9c63a

Please sign in to comment.