-
-
Notifications
You must be signed in to change notification settings - Fork 113
[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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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({ | ||
|
||
|
@@ -11,7 +13,18 @@ export default Mixin.create({ | |
}, | ||
|
||
didTransition() { | ||
this.get('scrollPositionReset').doReset(); | ||
this._super(); | ||
let isAnchorEmpty = window && window.location && window.location.search === '?anchor=' | ||
if ((typeof FastBoot === 'undefined') && isAnchorEmpty ) { | ||
let elem = $('#methods'); | ||
let offset = (elem && elem.offset && elem.offset()) ? elem.offset().top : null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also overly defensive. If it's JQuery object, it is safe to assume that
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. Sorry about the delay |
||
if (offset) { | ||
const navMenuHeight = $('header').outerHeight(); | ||
$(config.APP.scrollContainerSelector).scrollTop(offset - navMenuHeight - 10); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since header is no longer a fixed element on the page, do we still need to take navMenuHeight into consideration? Having a little space above the method doesn't look all bad There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There will be less space if we remove it :). But let's do it, I think the anchor is gonna be more clear. |
||
} | ||
} else { | ||
this.get('scrollPositionReset').doReset(); | ||
} | ||
} | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this seem hacky?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting anchor from the controller cannot be done from these places?
If we are not in FastBoot, it is safe to reach into
window.location.search
right away.(typeof FastBoot === 'undefined') && window.location.search === '?anchor=')
should be fine.This will also break if we have more than 1 queryParam, but this is probably fine. So far there no plans for adding more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. anchor is only available in child route's(
methods
) controller.I will update the check