Page MenuHomeSoftware Heritage

Hide back-to-top when on top

Authored by kalpitk on May 24 2019, 4:56 PM.



Related T1477

Diff Detail

rDWAPPS Web applications
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

anlambert added a subscriber: anlambert.
anlambert added inline comments.
214–222 ↗(On Diff #4975)

Apart script that require input embedded in the Django templates, Javascript code should be handled by webpack.

Thus this implementation should be moved in the file assets/src/bundles/webapp/webapp-utils.js at the end of the $(document).ready() callback starting at line 58.

All JS code handled by webpack can use jQuery and ES6 syntax so I would rather use the following implementation here:

let scrollThreshold = 0;
scrollThreshold += $('.swh-top-bar').height() || 0;
scrollThreshold += $('.navbar').height() || 0;
$(window).scroll(() => {
  if ($(window).scrollTop() > scrollThreshold) {
    $('#back-to-top').css('display', 'block');
  } else {
    $('#back-to-top').css('display', 'none');
This revision now requires changes to proceed.May 24 2019, 5:33 PM

moved js to webapp-utils.js

Thanks for this improvement !

This revision is now accepted and ready to land.May 24 2019, 10:02 PM
This revision was automatically updated to reflect the committed changes.