scikit-learn-mooc icon indicating copy to clipboard operation
scikit-learn-mooc copied to clipboard

Slightly off vertical placement when using anchors in links on FUN

Open lesteve opened this issue 3 years ago • 6 comments

@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":

image

This scrolls to: image

and I need to scroll-up a few lines to actually see the entry "predict". After scrolling up a bit: image

You can see that the "predict, prediction" entry and the first line was not visible before scrolling.

lesteve avatar Jul 21 '21 12:07 lesteve

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.

brospars avatar Jul 21 '21 12:07 brospars

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');
});

brospars avatar Jul 21 '21 12:07 brospars

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 ...

lesteve avatar Jul 21 '21 12:07 lesteve

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 ...

lesteve avatar Jul 22 '21 05:07 lesteve

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.

brospars avatar Jul 22 '21 07:07 brospars

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.

lesteve avatar Jul 22 '21 07:07 lesteve

Let's close this as good enough for now.

lesteve avatar Nov 23 '22 13:11 lesteve