Skip to content

Commit 43d462f

Browse files
Do not include header height while calculating scroll offset
1 parent 24391cf commit 43d462f

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

app/components/ember-anchor.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ export default AnchorComponent.extend({
1010
let qp = this.get('anchorQueryParam');
1111
let qpVal = this.get(get(this, 'attrs.a') ? 'a' : `controller.${qp}`);
1212
let elem = $(`[data-${qp}="${qpVal}"]`);
13-
let offset = (elem && elem.offset && elem.offset()) ? elem.offset().top : null;
13+
let offset = elem.offset() ? elem.offset().top : 0;
1414
if (offset) {
15-
const navMenuHeight = $('header').outerHeight();
16-
$(config.APP.scrollContainerSelector).scrollTop(offset - navMenuHeight - 10);
15+
$(config.APP.scrollContainerSelector).scrollTop(offset);
1716
}
1817
}
1918
});

app/mixins/scroll-tracker.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@ export default Mixin.create({
1414

1515
didTransition() {
1616
this._super();
17-
let isAnchorEmpty = window && window.location && window.location.search === '?anchor='
18-
if ((typeof FastBoot === 'undefined') && isAnchorEmpty ) {
17+
if ((typeof FastBoot === 'undefined') && window.location.search === '?anchor=' ) {
1918
let elem = $('#methods');
20-
let offset = (elem && elem.offset && elem.offset()) ? elem.offset().top : null;
19+
let offset = elem.offset() ? elem.offset().top : 0;
2120
if (offset) {
22-
const navMenuHeight = $('header').outerHeight();
23-
$(config.APP.scrollContainerSelector).scrollTop(offset - navMenuHeight - 10);
21+
$(config.APP.scrollContainerSelector).scrollTop(offset - 10);
22+
return;
2423
}
25-
} else {
26-
this.get('scrollPositionReset').doReset();
2724
}
25+
this.get('scrollPositionReset').doReset();
2826
}
2927
}
3028
});

0 commit comments

Comments
 (0)