Commit d45a8e00 authored by Fatih Acet's avatar Fatih Acet

IssueNotesRefactor: Make scroll into note an action.

parent 08d597c7
...@@ -94,12 +94,8 @@ export default { ...@@ -94,12 +94,8 @@ export default {
const $el = $(`#${hash}`); const $el = $(`#${hash}`);
if (hash && $el) { if (hash && $el) {
const isInViewport = gl.utils.isInViewport($el[0]);
this.$store.commit('setTargetNoteHash', hash); this.$store.commit('setTargetNoteHash', hash);
this.$store.dispatch('scrollToNoteIfNeeded', $el);
if (!isInViewport) {
gl.utils.scrollToElement($el);
}
} }
}, },
}, },
......
...@@ -214,6 +214,13 @@ const actions = { ...@@ -214,6 +214,13 @@ const actions = {
} }
}); });
}, },
scrollToNoteIfNeeded(context, el) {
const isInViewport = gl.utils.isInViewport(el[0]);
if (!isInViewport) {
gl.utils.scrollToElement(el);
}
},
}; };
export default { export default {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment