Skip to content
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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Created scrollTop feature #81

wants to merge 10 commits into from

Conversation

tranthaison1231
Copy link
Contributor

No description provided.

@nhim175 nhim175 changed the title Created scrollTop feater Created scrollTop feature Jun 18, 2019
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
});
window.onscroll = function() {scrollFunction()};
Copy link
Owner

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() {
Copy link
Owner

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;
Copy link
Owner

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;
});
Copy link
Owner

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");
}
}
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants