🐛 Avoid extra render calls on page initialization with wasm render (#5701)

This commit is contained in:
Alejandro 2025-01-29 10:50:27 +01:00 committed by GitHub
parent 979de39768
commit ce67550195
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 13 deletions

View file

@ -573,6 +573,19 @@
(rx/reduce conj [])
(rx/subs! request-render)))))
(defn set-canvas-background
[background]
(let [rgba (rgba-from-hex background 1)]
(h/call internal-module "_set_canvas_background" rgba)
(request-render "set-canvas-background")))
(defn initialize
[base-objects zoom vbox background]
(let [rgba (rgba-from-hex background 1)]
(h/call internal-module "_set_canvas_background" rgba)
(h/call internal-module "_set_view" zoom (- (:x vbox)) (- (:y vbox)))
(set-objects base-objects)))
(def ^:private canvas-options
#js {:antialias false
:depth true
@ -610,11 +623,6 @@
;; TODO: perform corresponding cleaning
(h/call internal-module "_clean_up"))
(defn set-canvas-background
[background]
(let [rgba (rgba-from-hex background 1)]
(h/call internal-module "_set_canvas_background" rgba)))
(defonce module
(delay
(if (exists? js/dynamicImport)