From 325682248a8e461f1ab59223815f8c8cf08bf1a7 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 16 May 2017 10:18:31 -0700 Subject: [PATCH] If there's an anchor in the URL in Differential, don't stick to the bottom of the page as content loads Summary: Fixes T11784. A lot of things are interacting here, but this probably gets slightly better results slightly more often? Basically: - When we load content, we try to keep the viewport "stable" on the page, so the page doesn't jump around like crazy. - If you're near the top or bottom of the page, we try to stick to the top (e.g., reading the summary) or bottom (e.g., writing a comment). - But, if you followed an anchor to a comment that's close to the bottom of the page, we might stick to the bottom intead of staying with the anchor. Kind of do a better job by not sticking to the bottom if you have an anchor. This will get things wrong if you follow an anchor, scroll down, start writing a comment, etc. But this whole thing is a pile of guesses anyway. Test Plan: - Followed an anchor, saw non-sticky stabilization. - Loaded the page normally, scrolled to the bottom real fast, saw sticky stabilization. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11784 Differential Revision: https://secure.phabricator.com/D17911 --- resources/celerity/map.php | 28 +++++++++---------- .../rsrc/js/application/diff/DiffChangeset.js | 6 ++++ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 7e2a517ed8..b389a84ba5 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -13,7 +13,7 @@ return array( 'core.pkg.js' => '8c5f913d', 'darkconsole.pkg.js' => '1f9a31bc', 'differential.pkg.css' => '58712637', - 'differential.pkg.js' => 'bd321b6e', + 'differential.pkg.js' => 'f1b636fb', 'diffusion.pkg.css' => 'b93d9b8c', 'diffusion.pkg.js' => '84c8f8fd', 'favicon.ico' => '30672e08', @@ -390,7 +390,7 @@ return array( 'rsrc/js/application/dashboard/behavior-dashboard-move-panels.js' => '408bf173', 'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '453c5375', 'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => 'd4eecc63', - 'rsrc/js/application/diff/DiffChangeset.js' => '145c34e2', + 'rsrc/js/application/diff/DiffChangeset.js' => 'c5742feb', 'rsrc/js/application/diff/DiffChangesetList.js' => 'f1101e6e', 'rsrc/js/application/diff/DiffInline.js' => 'bdf6b568', 'rsrc/js/application/diff/behavior-preview-link.js' => '051c7832', @@ -779,7 +779,7 @@ return array( 'phabricator-darklog' => 'c8e1ffe3', 'phabricator-darkmessage' => 'c48cccdd', 'phabricator-dashboard-css' => 'fe5b1869', - 'phabricator-diff-changeset' => '145c34e2', + 'phabricator-diff-changeset' => 'c5742feb', 'phabricator-diff-changeset-list' => 'f1101e6e', 'phabricator-diff-inline' => 'bdf6b568', 'phabricator-drag-and-drop-file-upload' => '58dea2fa', @@ -997,17 +997,6 @@ return array( 'javelin-dom', 'javelin-typeahead-normalizer', ), - '145c34e2' => array( - 'javelin-dom', - 'javelin-util', - 'javelin-stratcom', - 'javelin-install', - 'javelin-workflow', - 'javelin-router', - 'javelin-behavior-device', - 'javelin-vector', - 'phabricator-diff-inline', - ), '1499a8cb' => array( 'javelin-behavior', 'javelin-stratcom', @@ -1926,6 +1915,17 @@ return array( 'javelin-stratcom', 'phabricator-tooltip', ), + 'c5742feb' => array( + 'javelin-dom', + 'javelin-util', + 'javelin-stratcom', + 'javelin-install', + 'javelin-workflow', + 'javelin-router', + 'javelin-behavior-device', + 'javelin-vector', + 'phabricator-diff-inline', + ), 'c587b80f' => array( 'javelin-install', ), diff --git a/webroot/rsrc/js/application/diff/DiffChangeset.js b/webroot/rsrc/js/application/diff/DiffChangeset.js index ba018478a6..3130fced44 100644 --- a/webroot/rsrc/js/application/diff/DiffChangeset.js +++ b/webroot/rsrc/js/application/diff/DiffChangeset.js @@ -440,6 +440,12 @@ JX.install('DiffChangeset', { var near_top = (old_pos.y <= sticky); var near_bot = ((old_pos.y + old_view.y) >= (old_dim.y - sticky)); + // If we have an anchor in the URL, never stick to the bottom of the + // page. See T11784 for discussion. + if (window.location.hash) { + near_bot = false; + } + var target_pos = JX.Vector.getPos(target); var target_dim = JX.Vector.getDim(target); var target_mid = (target_pos.y + (target_dim.y / 2));