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
No Linters Available
No Unit Test Coverage
Build Status
Buildable 5925
Build 8116: tox-on-jenkinsJenkins
Build 8115: arc lint + arc unit

Event Timeline

kalpitk created this revision.May 24 2019, 4:56 PM
anlambert requested changes to this revision.May 24 2019, 5:33 PM
anlambert added a subscriber: anlambert.
anlambert added inline comments.

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
kalpitk updated this revision to Diff 4977.May 24 2019, 7:15 PM

moved js to webapp-utils.js

anlambert accepted this revision.May 24 2019, 10:02 PM

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.