Title says it all.

Otherwise this feels kind of uncanny: when you've scrolled far down and then click a link which leads you to a page that also contains a lot of content, you'll be equally far down on that new page as you were on the previous page. This allows the user to clearly feel something is off. We don't want that.

CommentFileSizeAuthor
#3 2713499-3.patch1.08 KBWim Leers
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers created an issue. See original summary.

Wim Leers’s picture

Title: When navigating to a new page, it should be scrolled to the top, just like without RefreshLes » When navigating to a new page, it should be scrolled to the top, just like without RefreshLess
Wim Leers’s picture

Status: Active » Needs review
FileSize
1.08 KB
Wim Leers’s picture

+++ b/js/refreshless.js
@@ -270,10 +272,11 @@
-          location.assign('#' + target.fragment);
+          var element = document.getElementById(target.fragment);
+          if (element) {
+            element.scrollIntoView();
+          }

This change is necessary due to different behaviors in different browsers:

  • Google Chrome doesn't create a new history entry for location.assign() (perhaps intentionally, perhaps due to a race condition, who knows)
  • But Firefox does

Therefore I had to resort to manual scrolling for this. Fortunately we have a good API for just that.

Wim Leers’s picture

Title: When navigating to a new page, it should be scrolled to the top, just like without RefreshLess » When navigating to a new page, it should be scrolled to the top + navigating to a fragment on another page broken in Firefox
Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

Now that we have manual scrolling in place, and it turns out to be trivial, we might as well do that when navigating to a fragment on the current page too, because that'd allow us to remove our onhashchange event handler. Let's do that in a follow-up.

Wim Leers’s picture

Status: Reviewed & tested by the community » Fixed

  • Wim Leers committed a310175 on 8.x-1.x
    Issue #2713499 by Wim Leers: When navigating to a new page, it should be...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.