Skip to content

[Bugfix]Fix autoscroll to methods issue #321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions app/components/ember-anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ export default AnchorComponent.extend({
let qp = this.get('anchorQueryParam');
let qpVal = this.get(get(this, 'attrs.a') ? 'a' : `controller.${qp}`);
let elem = $(`[data-${qp}="${qpVal}"]`);
let offset = (elem && elem.offset && elem.offset()) ? elem.offset().top : null;
let offset = elem.offset() ? elem.offset().top : 0;
if (offset) {
const navMenuHeight = $('header').outerHeight();
$(config.APP.scrollContainerSelector).scrollTop(offset - navMenuHeight - 10);
$(config.APP.scrollContainerSelector).scrollTop(offset);
}
}
});
11 changes: 11 additions & 0 deletions app/mixins/scroll-tracker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Mixin from '@ember/object/mixin';
import { inject as service } from '@ember/service';
import $ from 'jquery';
import config from 'ember-api-docs/config/environment';

export default Mixin.create({

Expand All @@ -11,6 +13,15 @@ export default Mixin.create({
},

didTransition() {
this._super();
if ((typeof FastBoot === 'undefined') && window.location.search === '?anchor=' ) {
let elem = $('#methods');
let offset = elem.offset() ? elem.offset().top : 0;
if (offset) {
$(config.APP.scrollContainerSelector).scrollTop(offset - 10);
return;
}
}
this.get('scrollPositionReset').doReset();
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/routes/project-version/namespaces/namespace.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ClassRoute from '../classes/class';
import ScrollTracker from 'ember-api-docs/mixins/scroll-tracker';

export default ClassRoute.extend({
export default ClassRoute.extend(ScrollTracker, {
templateName: 'project-version/classes/class',

model(params, transition) {
Expand Down
9 changes: 5 additions & 4 deletions app/templates/project-version/classes/class.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
model.project.id
model.projectVersion.compactVersion
model.name
(query-params anchor="")
(query-params anchor=undefined)
class="tabbed-layout__menu__item"
activeClass="tabbed-layout__menu__item_selected"
current-when=(concat parentName ".index")
Expand All @@ -60,9 +60,10 @@
model.project.id
model.projectVersion.compactVersion
model.name
(query-params anchor="")
(query-params anchor=undefined)
class="tabbed-layout__menu__item"
activeClass="tabbed-layout__menu__item_selected"
id="methods"
current-when=(concat parentName ".methods")
data-test-tab="methods"
}}
Expand All @@ -74,7 +75,7 @@
model.project.id
model.projectVersion.compactVersion
model.name
(query-params anchor="")
(query-params anchor=undefined)
class="tabbed-layout__menu__item"
activeClass="tabbed-layout__menu__item_selected"
current-when=(concat parentName ".properties")
Expand All @@ -88,7 +89,7 @@
model.project.id
model.projectVersion.compactVersion
model.name
(query-params anchor="")
(query-params anchor=undefined)
class="tabbed-layout__menu__item"
activeClass="tabbed-layout__menu__item_selected"
current-when=(concat parentName ".events")
Expand Down