fix: prevent scroll errors

This commit is contained in:
EnixCoda 2018-08-07 21:32:13 +08:00
parent 83815ea051
commit 995421642d

View file

@ -58,10 +58,13 @@ function scrollToRepoContent() {
function scrollToNodeElement(index) {
const nodeElementSelector = '.node-item'
const nodeElements = document.querySelectorAll(nodeElementSelector)
nodeElements[index].scrollIntoView({
behavior: 'smooth',
block: 'center',
})
const targetElement = nodeElements[index]
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth',
block: 'center',
})
}
}
const pjax = new PJAX({