From 3643612b1cbe4a08044e424cac3f775a23bdb774 Mon Sep 17 00:00:00 2001 From: Dennis Schubert Date: Tue, 6 Mar 2018 11:33:52 +0100 Subject: [PATCH] Back to Top: Make sure to re-check the visibility after the scrolling is done If a user scrolls just below the 1000px threshold and clicks the back-to-top button within 250ms, we'll never hide the button as the scroll event gets throttled away. That's rather inconvenient. closes #7729 --- Changelog.md | 1 + app/assets/javascripts/app/views/back_to_top_view.js | 2 +- spec/javascripts/app/views/back_to_top_view_spec.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 3e13b6269..2835f4c73 100644 --- a/Changelog.md +++ b/Changelog.md @@ -13,6 +13,7 @@ ## Features * Add basic html5 audio/video embedding support [#6418](https://github.com/diaspora/diaspora/pull/6418) +* Add the back-to-top button to all pages [#7729](https://github.com/diaspora/diaspora/pull/7729) # 0.7.3.1 diff --git a/app/assets/javascripts/app/views/back_to_top_view.js b/app/assets/javascripts/app/views/back_to_top_view.js index 0289c8fb0..f04c76432 100644 --- a/app/assets/javascripts/app/views/back_to_top_view.js +++ b/app/assets/javascripts/app/views/back_to_top_view.js @@ -12,7 +12,7 @@ app.views.BackToTop = Backbone.View.extend({ backToTop: function(evt) { evt.preventDefault(); - $("html, body").animate({scrollTop: 0}); + $("html, body").animate({scrollTop: 0}, this.toggleVisibility); }, toggleVisibility: function() { diff --git a/spec/javascripts/app/views/back_to_top_view_spec.js b/spec/javascripts/app/views/back_to_top_view_spec.js index 726c1ae1b..99d33b541 100644 --- a/spec/javascripts/app/views/back_to_top_view_spec.js +++ b/spec/javascripts/app/views/back_to_top_view_spec.js @@ -17,7 +17,7 @@ describe("app.views.BackToTop", function() { it("scrolls to the top of the page", function() { var spy = spyOn($.fn, "animate"); this.view.backToTop($.Event()); - expect(spy).toHaveBeenCalledWith({scrollTop: 0}); + expect(spy).toHaveBeenCalledWith({scrollTop: 0}, jasmine.any(Function)); }); });