提交 d45a8e00 编写于 作者: F Fatih Acet

IssueNotesRefactor: Make scroll into note an action.

上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册