fix(plugin): check if scroll target exists in animation plugin

This commit is contained in:
ppoffice 2022-09-30 22:54:48 -04:00
parent e59fe64bb1
commit 436e134d5a
No known key found for this signature in database
GPG Key ID: D872802C1F2A16AA
1 changed files with 5 additions and 2 deletions

View File

@ -52,8 +52,11 @@
// jump to location.hash
if (window.location.hash) {
setTimeout(() => {
// Use getElementById because querySelector does not support ids that start with numbers
document.getElementById(window.location.hash.substring(1)).scrollIntoView({ behavior: 'smooth' });
const id = '#' + CSS.escape(window.location.hash.substring(1));
const target = document.querySelector(id);
if (target) {
target.scrollIntoView({ behavior: 'smooth' });
}
}, i * 100);
}
});