Skip to content

Commit

Permalink
Merge pull request #492 from datdamnzotz/Fix-Page-not-loading-to-top
Browse files Browse the repository at this point in the history
Added Force a scroll to top of page on builders
  • Loading branch information
datdamnzotz authored Dec 29, 2020
2 parents fc73c5f + dd3a8c2 commit afe2f6a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/cljs/orcpub/character_builder.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@

[reagent.core :as r]
[re-frame.core :refer [subscribe dispatch dispatch-sync]]))

(def print-disabled? false)
;console-print
(def print-disabled? true)

(def print-enabled? (and (not print-disabled?)
js/window.location
Expand Down Expand Up @@ -2032,6 +2032,7 @@
@(subscribe [::char5e/character-changed? character-id])
(not= db/default-character character))]
(if print-enabled? (print-char built-char))
(if (not character-changed?) (js/window.scrollTo 0,0)) ;//Force a scroll to top of page only if we are not editing.
[views5e/content-page
"Character Builder"
(remove
Expand Down Expand Up @@ -2066,7 +2067,7 @@
"Update Existing Character"
"Save New Character")
:icon "save"
:style (if character-changed? unsaved-button-style)
:style (if character-changed? unsaved-button-style)
:on-click save-character}
(if (:db/id character)
{:title "View"
Expand Down
3 changes: 2 additions & 1 deletion src/cljs/orcpub/dnd/e5/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,8 @@
(r/create-class
{:component-did-mount (fn [comp]
(when-not frame?
(js/window.addEventListener "scroll" on-scroll)))
(js/window.addEventListener "scroll" on-scroll))
(js/window.scrollTo 0,0))
:component-will-unmount (fn [comp]
(when-not frame?
(js/window.removeEventListener "scroll" on-scroll)))
Expand Down

0 comments on commit afe2f6a

Please sign in to comment.