Fix anchor-clicking scroll positions

Summary:
Fixes T7069. When jumping to a comment anchor, we get the scroll positions wrong.

Partly this is fixing some calcaulations; partly, the "show older comments" and "scroll anchor" stuff were fighting over the scroll position. Since the anchor can take care of things on its own, just let it handle stuff.

Test Plan:
  - Clicked comment anchors.
  - Loaded pages with anchors in the URI.
  - Loaded pages with anchors hidden behind "show older comments".

In all cases, got the right scroll position.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T7069

Differential Revision: https://secure.phabricator.com/D11540
This commit is contained in:
epriestley
2015-01-28 08:26:10 -08:00
parent 48f15fb960
commit eaa883cf37
6 changed files with 69 additions and 57 deletions

View File

@@ -39,7 +39,9 @@ JX.behavior('phabricator-watch-anchor', function() {
var n = 50;
var try_anchor_again = function () {
try {
JX.DOM.scrollToPosition(0, JX.$V(JX.$(anchor)).y - 60);
var node = JX.$(anchor);
var pos = JX.Vector.getPosWithScroll(node);
JX.DOM.scrollToPosition(0, pos.y - 60);
defer_highlight();
} catch (e) {
if (n--) {