Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix auto-scroll undershooting correction location on initial page load #2238

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

nrankin18
Copy link

Summary

Bug: Navigating to an anchor link on docs with images causes the initial auto-scroll to "undershoot" the correct location. This is because the scroll location is calculated prior to the images loading, so the image heights aren't accounted for in the location calculation.

Fix: Wait for the document to finish loading and then scroll to the location. After scrolling to the location, call el.scrollIntoView() as a backup.

Additional Bug: Auto-scroll on an initial page load does not scroll the appropriate sidebar item into view. This is because #highlight() is blocked while the Tweezer animation is running and will not scroll the sidebar if the item is already active.

Fix: Call #highlight() after the Tweezer scroll animation is complete with a parameter to force the scroll.

Related issue, if any:

#351
#559

What kind of change does this PR introduce?

Bugfix

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed

Does this PR introduce a breaking change?

No

Tested in the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Edge

@vercel
Copy link

vercel bot commented Sep 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docsify-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2023 5:33am

}
}, 100);
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this reliable? Does the page go into non-complete ready state on each markdown fetch/render? If not, perhaps we should instead track images (etc) ourself, and wait for load event on all of them. Need to check this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants