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

IssueNotesRefactor: Make scroll into note an action.

上级 08d597c7
......@@ -94,12 +94,8 @@ export default {
const $el = $(`#${hash}`);
if (hash && $el) {
const isInViewport = gl.utils.isInViewport($el[0]);
this.$store.commit('setTargetNoteHash', hash);
if (!isInViewport) {
gl.utils.scrollToElement($el);
}
this.$store.dispatch('scrollToNoteIfNeeded', $el);
}
},
},
......
......@@ -214,6 +214,13 @@ const actions = {
}
});
},
scrollToNoteIfNeeded(context, el) {
const isInViewport = gl.utils.isInViewport(el[0]);
if (!isInViewport) {
gl.utils.scrollToElement(el);
}
},
};
export default {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册