scikit-learn-mooc
scikit-learn-mooc copied to clipboard
Slightly off vertical placement when using anchors in links on FUN
@brospars input on this more than welcome! Wild-guess: could it be due to the fix of the weird scrolling in FUN on the left-hand side panel (I am reasonably sure it was working fine at one point ...)?
Go to the glossary and click on "predict":
This scrolls to:
and I need to scroll-up a few lines to actually see the entry "predict". After scrolling up a bit:
You can see that the "predict, prediction" entry and the first line was not visible before scrolling.
Yes it's related to the fix of the unwanted left-hand side panel scrolling... I removed smooth scrolling to fix unwanted scrolling outside of course content. That's what happen when you hack an app without a proper API, it often has unwanted side effects. Should be easy to fix.
Fixed.
The repository is private but here's the code :
$(document).on('click', '.course-content a[href^=#], .static_tab_wrapper a[href^=#]', function(e) {
e.preventDefault();
var aid = $(this).attr("href").replace('#','')
$('html,body').animate({scrollTop: $('[id="'+aid+'"]').offset().top - $('#top-menu').height()},'slow');
});
Nice, I doubled-check and with a hard refresh it work indeed, thanks a lot!
Do you have a commit diff somewhere for me to look at, I would love to be less dumb regarding this js magic ...
This affects any anchor actually right? For example this link is supposed to go to "Question 6" but actually ends up being a bit too low ...
It's a different problem. I capture anchor links being clicked not anchor in the URL. I'll take a look if that's doable despite my javascript being loaded last.
OK to be honest, it is not such a big deal because it is quite unlikely that MOOC users will have this problem.
For some context: I bumped into the last problem when trying to create links to particular quiz questions for convenience. We can very easily scroll up a few lines.
Let's close this as good enough for now.