Add check for container-element

This commit is contained in:
Vitaliy Vlasov 2018-01-26 12:46:50 +02:00
parent dbffabffe0
commit 3813e19150
1 changed files with 4 additions and 2 deletions

View File

@ -45,7 +45,8 @@
{:class "grayed-out-page-num" {:class "grayed-out-page-num"
:on-click #(do :on-click #(do
(rf/dispatch [:set-page-number i]) (rf/dispatch [:set-page-number i])
(.scrollIntoView @container-element))}) (when @container-element
(.scrollIntoView @container-element)))})
i]) i])
max-page-nums 6] max-page-nums 6]
[:div.page-nums-container [:div.page-nums-container
@ -97,7 +98,8 @@
(if forward? (if forward?
(inc page-number) (inc page-number)
(dec page-number))]) (dec page-number))])
(.scrollIntoView @container-element))) (when @container-element
(.scrollIntoView @container-element))))
draw-rect (fn [direction] draw-rect (fn [direction]
(let [forward? (= direction :forward) (let [forward? (= direction :forward)
gray-out? (or (and forward? (= page-number page-count)) gray-out? (or (and forward? (= page-number page-count))