-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
[UX] Approximate scroll when we click on sidebar menu title #6
Comments
👍 |
Figured out that temp solution with jquery (we can do without) by hiding the top menu bar. _nav.sass: .nav-up
top: -100px; head.html <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha256-4+XzXVhsDmqanXGHaHvgh1gMQKX40OUvDEBTu8JcmNs=" crossorigin="anonymous"></script> index.js: $(function() {
var hasClicked = false;
// hide bar when clicking on a menu item
$(".toc_item a").on('click', function(event) {
hasClicked = true;
$('.nav_header').removeClass('nav-down').addClass('nav-up');
});
// Hide Header on on scroll down
var didScroll;
var lastScrollTop = 0;
var delta = 50;
var navbarHeight = $('.nav_header').outerHeight();
$(window).scroll(function(event){
didScroll = true;
});
setInterval(function() {
if (didScroll) {
hasScrolled();
didScroll = false;
hasClicked = false;
}
}, 500);
function hasScrolled() {
var st = $(this).scrollTop();
// Make sure they scroll more than delta
if(Math.abs(lastScrollTop - st) <= delta)
return;
// If they scrolled down and are past the navbar, add class .nav-up.
// This is necessary so you never see what is "behind" the navbar.
if (st > lastScrollTop && st > navbarHeight){
// Scroll Down
$('.nav_header').removeClass('nav-down').addClass('nav-up');
} else {
// Scroll Up
if(st + $(window).height() < $(document).height()) {
if (hasClicked != true) {
$('.nav_header').removeClass('nav-up').addClass('nav-down');
}
}
}
lastScrollTop = st;
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When we click on an element of the left side menu , the scroll brings it (approximately) to the content, sometimes at the wrong section.
For example, that link should bring to the video section, but it bring it to the middle of the content:
I think the correct behaviour would be to bring it exactly to the heading title?
The text was updated successfully, but these errors were encountered: