-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created scrollTop feature #81
base: master
Are you sure you want to change the base?
Conversation
document.body.scrollTop = 0; | ||
document.documentElement.scrollTop = 0; | ||
}); | ||
window.onscroll = function() {scrollFunction()}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
window.onscroll = onScroll
document.documentElement.scrollTop = 0; | ||
}); | ||
window.onscroll = function() {scrollFunction()}; | ||
function scrollFunction() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function onScroll
display: flex; | ||
justify-content: center; | ||
display: flex; | ||
justify-content: center; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 space tab
scrollTopEl.addEventListener("click", () => { | ||
document.body.scrollTop = 0; | ||
document.documentElement.scrollTop = 0; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tranthaison1231 hiện tại mình đang dùng thư viện này để làm smooth scroll https://github.com/cferdinandi/smooth-scroll
Em học cách dùng rồi áp dụng
} else { | ||
scrollTopEl.classList.remove("showScroll"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
để performance tốt hơn thì nên sử dụng debounce hoặc throttle để giảm số lần hàm onScroll
bị gọi
No description provided.