Update window width state when window resizes

Fixes #26
This commit is contained in:
Daniel Compton 2017-10-20 15:08:23 +13:00
parent 05656af0b9
commit 2858a0ff6c
1 changed files with 35 additions and 30 deletions

View File

@ -325,6 +325,9 @@
pin-to-bottom? (r/atom true)
selected-tab (r/atom :traces)
window-width (r/atom js/window.innerWidth)
handle-window-resize (fn [e]
;; N.B. I don't think this should be a perf bottleneck.
(reset! window-width js/window.innerWidth))
handle-keys (fn [e]
(let [combo-key? (or (.-ctrlKey e) (.-metaKey e) (.-altKey e))
tag-name (.-tagName (.-target e))
@ -359,11 +362,13 @@
(toggle-traces showing?)
(js/window.addEventListener "keydown" handle-keys)
(js/window.addEventListener "mousemove" handle-mousemove)
(js/window.addEventListener "mouseup" handle-mouse-up))
(js/window.addEventListener "mouseup" handle-mouse-up)
(js/window.addEventListener "resize" handle-window-resize))
:component-will-unmount (fn []
(js/window.removeEventListener "keydown" handle-keys)
(js/window.removeEventListener "mousemove" handle-mousemove)
(js/window.removeEventListener "mouseup" handle-mouse-up))
(js/window.removeEventListener "mouseup" handle-mouse-up)
(js/window.removeEventListener "resize" handle-window-resize))
:display-name "devtools outer"
:reagent-render (fn []
(let [draggable-area 10