add null handling and fix merge conflicts
This commit is contained in:
parent
8580a1f463
commit
6e0a4b058d
4 changed files with 37 additions and 34 deletions
|
@ -40,19 +40,21 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||
// add scroll to top button
|
||||
const btn = document.getElementById('scroll-to-top')
|
||||
|
||||
window.addEventListener('scroll', function () {
|
||||
if (window.scrollY > 300) {
|
||||
btn.classList.add('show')
|
||||
} else {
|
||||
btn.classList.remove('show')
|
||||
}
|
||||
})
|
||||
|
||||
btn.addEventListener('click', function (e) {
|
||||
e.preventDefault()
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
behavior: 'smooth'
|
||||
if(btn) {
|
||||
window.addEventListener('scroll', function () {
|
||||
if (window.scrollY > 300) {
|
||||
btn.classList.add('show')
|
||||
} else {
|
||||
btn.classList.remove('show')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
btn.addEventListener('click', function (e) {
|
||||
e.preventDefault()
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
behavior: 'smooth'
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue