mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-31 18:01:00 +01:00
Improve Differential behavior when scrolling with anchors
Summary: Fixes T12779. Currently, we scroll down if the midline of the changeset is above the midline of the viewport. This rule can cause us to scroll improperly when loading changesets //after// jumping to their anchors, since the changeset we want to look at will likely have a midpoint above the document midline. That is, we follow an anchor to `X.c`, then it loads, then we scroll past it. Instead, scroll only if the changeset is (almost) entirely above the viewport. Test Plan: Followed an anchor to `PHUIFeedStoryExample`: {F4984154} Reviewers: chad Reviewed By: chad Maniphest Tasks: T12779 Differential Revision: https://secure.phabricator.com/D18052
This commit is contained in:
parent
c5bb69fd7d
commit
d161a07781
1 changed files with 14 additions and 8 deletions
|
@ -501,12 +501,17 @@ JX.install('DiffChangeset', {
|
|||
// diff with a large number of changes don't constantly have the text
|
||||
// area scrolled off the bottom of the screen until the entire diff loads.
|
||||
//
|
||||
// There are two three major cases here:
|
||||
// There are several major cases here:
|
||||
//
|
||||
// - If we're near the top of the document, never scroll.
|
||||
// - If we're near the bottom of the document, always scroll.
|
||||
// - Otherwise, scroll if the changes were above the midline of the
|
||||
// viewport.
|
||||
// - If we're near the bottom of the document, always scroll, unless
|
||||
// we have an anchor.
|
||||
// - Otherwise, scroll if the changes were above (or, at least,
|
||||
// almost entirely above) the viewport.
|
||||
//
|
||||
// We don't scroll if the changes were just near the top of the viewport
|
||||
// because this makes us scroll incorrectly when an anchored change is
|
||||
// visible. See T12779.
|
||||
|
||||
var target = this._node;
|
||||
|
||||
|
@ -529,17 +534,18 @@ JX.install('DiffChangeset', {
|
|||
|
||||
var target_pos = JX.Vector.getPos(target);
|
||||
var target_dim = JX.Vector.getDim(target);
|
||||
var target_mid = (target_pos.y + (target_dim.y / 2));
|
||||
var target_bot = (target_pos.y + target_dim.y);
|
||||
|
||||
var view_mid = (old_pos.y + (old_view.y / 2));
|
||||
var above_mid = (target_mid < view_mid);
|
||||
// Detect if the changeset is entirely (or, at least, almost entirely)
|
||||
// above us.
|
||||
var above_screen = (target_bot < old_pos.y + 128);
|
||||
|
||||
var frame = this._getContentFrame();
|
||||
JX.DOM.setContent(frame, JX.$H(response.changeset));
|
||||
|
||||
if (this._stabilize) {
|
||||
if (!near_top) {
|
||||
if (near_bot || above_mid) {
|
||||
if (near_bot || above_screen) {
|
||||
// Figure out how much taller the document got.
|
||||
var delta = (JX.Vector.getDocument().y - old_dim.y);
|
||||
JX.DOM.scrollToPosition(old_pos.x, old_pos.y + delta);
|
||||
|
|
Loading…
Reference in a new issue