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
This commit is contained in:
Dennis Schubert 2018-03-06 11:33:52 +01:00 committed by Benjamin Neff
parent 8e88f4b183
commit 3643612b1c
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
3 changed files with 3 additions and 2 deletions

View file

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

View file

@ -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() {

View file

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