Skip to content

Commit e4f1924

Browse files
[Bugfix]Fix autoscroll to methods issue
1 parent 2d00b25 commit e4f1924

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

app/mixins/scroll-tracker.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import Mixin from '@ember/object/mixin';
22
import { inject as service } from '@ember/service';
3+
import $ from 'jquery';
4+
import config from 'ember-api-docs/config/environment';
35

46
export default Mixin.create({
57

@@ -11,7 +13,17 @@ export default Mixin.create({
1113
},
1214

1315
didTransition() {
14-
this.get('scrollPositionReset').doReset();
16+
this._super();
17+
if ((typeof FastBoot === 'undefined') && this.get('controller.anchor') === '' ) {
18+
let elem = $('#methods');
19+
let offset = (elem && elem.offset && elem.offset()) ? elem.offset().top : null;
20+
if (offset) {
21+
const navMenuHeight = $('header').outerHeight();
22+
$(config.APP.scrollContainerSelector).scrollTop(offset - navMenuHeight - 10);
23+
}
24+
} else {
25+
this.get('scrollPositionReset').doReset();
26+
}
1527
}
1628
}
1729
});

app/routes/project-version/namespaces/namespace.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import ClassRoute from '../classes/class';
2+
import ScrollTracker from 'ember-api-docs/mixins/scroll-tracker';
23

3-
export default ClassRoute.extend({
4+
export default ClassRoute.extend(ScrollTracker, {
45
templateName: 'project-version/classes/class',
56

67
model(params, transition) {

app/templates/project-version/classes/class.hbs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
model.project.id
4848
model.projectVersion.compactVersion
4949
model.name
50-
(query-params anchor="")
50+
(query-params anchor=undefined)
5151
class="tabbed-layout__menu__item"
5252
activeClass="tabbed-layout__menu__item_selected"
5353
current-when=(concat parentName ".index")
@@ -60,9 +60,10 @@
6060
model.project.id
6161
model.projectVersion.compactVersion
6262
model.name
63-
(query-params anchor="")
63+
(query-params anchor=undefined)
6464
class="tabbed-layout__menu__item"
6565
activeClass="tabbed-layout__menu__item_selected"
66+
id="methods"
6667
current-when=(concat parentName ".methods")
6768
data-test-tab="methods"
6869
}}
@@ -74,7 +75,7 @@
7475
model.project.id
7576
model.projectVersion.compactVersion
7677
model.name
77-
(query-params anchor="")
78+
(query-params anchor=undefined)
7879
class="tabbed-layout__menu__item"
7980
activeClass="tabbed-layout__menu__item_selected"
8081
current-when=(concat parentName ".properties")
@@ -88,7 +89,7 @@
8889
model.project.id
8990
model.projectVersion.compactVersion
9091
model.name
91-
(query-params anchor="")
92+
(query-params anchor=undefined)
9293
class="tabbed-layout__menu__item"
9394
activeClass="tabbed-layout__menu__item_selected"
9495
current-when=(concat parentName ".events")

0 commit comments

Comments
 (0)