Skip to content

Commit c7dd461

Browse files
[Bugfix]Fix autoscroll to methods issue
1 parent 61339a8 commit c7dd461

File tree

2 files changed

+18
-1
lines changed
  • app
    • routes/project-version/namespaces/namespace
    • templates/project-version/classes

2 files changed

+18
-1
lines changed
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
import Route from '@ember/routing/route';
2+
import { isEmpty } from '@ember/utils';
3+
import $ from 'jquery';
4+
import config from 'ember-api-docs/config/environment';
25

36
export default Route.extend({
4-
templateName: 'methods'
7+
templateName: 'methods',
8+
actions: {
9+
didTransition() {
10+
this._super();
11+
if ((typeof FastBoot === 'undefined') && isEmpty(this.get('controller.anchor'))) {
12+
let elem = $('#methods');
13+
let offset = (elem && elem.offset && elem.offset()) ? elem.offset().top : null;
14+
if (offset) {
15+
const navMenuHeight = $('header').outerHeight();
16+
$(config.APP.scrollContainerElement).scrollTop(offset - navMenuHeight - 10);
17+
}
18+
}
19+
}
20+
}
521
});

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
(query-params anchor="")
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
}}

0 commit comments

Comments
 (0)