You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
there are a few minor improvements and issues to consider:
-- Unnecessary use of this: In the scroll event listener, this refers to the window object. It's more clear to use document directly.
-- Performance considerations: Adding and removing a class on every scroll event can cause performance issues. Consider debouncing the scroll event to improve performance.
To Improve JS script:
`let lastKnownScrollPosition = 0;
let ticking = false;
window.addEventListener('scroll', function () {
lastKnownScrollPosition = window.scrollY;
there are a few minor improvements and issues to consider:
-- Unnecessary use of this: In the scroll event listener, this refers to the window object. It's more clear to use document directly.
-- Performance considerations: Adding and removing a class on every scroll event can cause performance issues. Consider debouncing the scroll event to improve performance.
To Improve JS script:
`let lastKnownScrollPosition = 0;
let ticking = false;
window.addEventListener('scroll', function () {
lastKnownScrollPosition = window.scrollY;
if (!ticking) {
window.requestAnimationFrame(function () {
if (lastKnownScrollPosition >= 720) {
document.body.classList.add('sticky');
} else {
document.body.classList.remove('sticky');
}
ticking = false;
});
}
});`
The text was updated successfully, but these errors were encountered: