Skip to content

Commit

Permalink
webview js [nfc]: Make at-bottom logic more explicit in resize handler.
Browse files Browse the repository at this point in the history
This version is algebraically equivalent... but seems more like what
we really mean here.
  • Loading branch information
gnprice committed May 5, 2020
1 parent b88af49 commit d047118
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/webview/js/generatedEs3.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ var compiledWebviewJs = (function (exports) {
window.addEventListener('resize', function (event) {
var heightChange = documentBody.clientHeight - viewportHeight;
viewportHeight = documentBody.clientHeight;
var maxScrollTop = documentBody.scrollHeight - documentBody.clientHeight;
if (documentBody.scrollHeight === documentBody.scrollTop + documentBody.clientHeight) {
if (documentBody.scrollTop === maxScrollTop) {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/webview/js/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ window.addEventListener('resize', event => {
// higher than we started.
//
// If that happened, we'll be at the very bottom now.
if (documentBody.scrollHeight === documentBody.scrollTop + documentBody.clientHeight) {
const maxScrollTop = documentBody.scrollHeight - documentBody.clientHeight;
if (documentBody.scrollTop === maxScrollTop) {
// We're at the very bottom of the content. Don't scroll.
//
// This does mean if you're near the bottom, and then the viewport grows
Expand Down

0 comments on commit d047118

Please sign in to comment.