File tree Expand file tree Collapse file tree 3 files changed +17
-15
lines changed Expand file tree Collapse file tree 3 files changed +17
-15
lines changed Original file line number Diff line number Diff line change 1
1
import { get } from '@ember/object' ;
2
2
import AnchorComponent from 'ember-anchor/components/ember-anchor' ;
3
3
import config from 'ember-api-docs/config/environment' ;
4
+ import getOffset from 'ember-api-docs/utils/get-offset' ;
4
5
5
6
export default AnchorComponent . extend ( {
6
- getOffset ( element , container ) {
7
- let offsetTop = element . offsetTop ;
8
- let parent = element . offsetParent ;
9
- while ( parent != null && parent != container ) {
10
- offsetTop += parent . offsetTop ;
11
- parent = parent . offsetParent ;
12
- }
13
- return offsetTop ;
14
- } ,
15
-
16
7
// This overrides Ember Anchor to support scrolling within a fixed position element
17
8
_scrollToElemPosition ( ) {
18
9
let qp = this . anchorQueryParam ;
@@ -21,7 +12,7 @@ export default AnchorComponent.extend({
21
12
let offset = elem . offsetHeight ? elem . offsetHeight : 0 ;
22
13
23
14
if ( offset ) {
24
- const offsetTop = this . getOffset ( elem , config . APP . scrollContainerSelector )
15
+ const offsetTop = getOffset ( elem , config . APP . scrollContainerSelector )
25
16
document . querySelector ( config . APP . scrollContainerSelector ) . scrollTo ( 0 , offsetTop ) ;
26
17
}
27
18
}
Original file line number Diff line number Diff line change 1
1
import Mixin from '@ember/object/mixin' ;
2
2
import { inject as service } from '@ember/service' ;
3
- import $ from 'jquery' ;
4
3
import config from 'ember-api-docs/config/environment' ;
4
+ import getOffset from 'ember-api-docs/utils/get-offset' ;
5
5
6
6
export default Mixin . create ( {
7
7
@@ -15,10 +15,12 @@ export default Mixin.create({
15
15
didTransition ( ) {
16
16
this . _super ( ) ;
17
17
if ( ( typeof FastBoot === 'undefined' ) && window . location . search === '?anchor=' ) {
18
- let elem = $ ( '#methods' ) ;
19
- let offset = elem . offset ( ) ? elem . offset ( ) . top : 0 ;
18
+ let elem = document . querySelector ( '#methods' ) ;
19
+ let offset = elem . offsetHeight ? elem . offsetHeight : 0 ;
20
+
20
21
if ( offset ) {
21
- $ ( config . APP . scrollContainerSelector ) . scrollTop ( offset - 10 ) ;
22
+ const offsetTop = getOffset ( elem , config . APP . scrollContainerSelector )
23
+ document . querySelector ( config . APP . scrollContainerSelector ) . scrollTo ( 0 , offsetTop - 10 ) ;
22
24
return ;
23
25
}
24
26
}
Original file line number Diff line number Diff line change
1
+ export default function getOffset ( element , container ) {
2
+ let offsetTop = element . offsetTop ;
3
+ let parent = element . offsetParent ;
4
+ while ( parent != null && parent != container ) {
5
+ offsetTop += parent . offsetTop ;
6
+ parent = parent . offsetParent ;
7
+ }
8
+ return offsetTop ;
9
+ }
You can’t perform that action at this time.
0 commit comments