Skip to content

Commit 6aef3b5

Browse files
committed
added auto scrollTop on navigation and changed page root element class name
1 parent 589c834 commit 6aef3b5

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

app/concepts/matestack/ui/core/app/store.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ const store = new Vuex.Store({
2727
},
2828
resetPageTemplate (state) {
2929
state.pageTemplate = null;
30+
},
31+
pageScrollTop (state) {
32+
//https://stackoverflow.com/a/35940276/13886137
33+
const getScrollParent = function(node) {
34+
if (node == null) {
35+
return null
36+
}
37+
if (node.scrollHeight > node.clientHeight) {
38+
return node
39+
} else {
40+
return getScrollParent(node.parentNode)
41+
}
42+
}
43+
getScrollParent(document.getElementsByClassName("matestack-page-root")[0]).scrollTop = 0
3044
}
3145
},
3246
actions: {
@@ -61,6 +75,7 @@ const store = new Vuex.Store({
6175
commit('setPageTemplate', response["data"])
6276
commit('setCurrentLocation', { path: url.split("?")[0], search: document.location.search, origin: document.location.origin })
6377
commit('setPageLoading', false)
78+
commit('pageScrollTop')
6479
matestackEventHub.$emit("page_loaded", url);
6580
if (typeof matestackUiCoreTransitionSuccess !== 'undefined') {
6681
matestackUiCoreTransitionSuccess(url);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
%div{class: "matestack-page"}
1+
%div{class: "matestack-page-root"}
22
- @children.each do |child|
33
= child.show

0 commit comments

Comments
 (0)