File tree 1 file changed +10
-5
lines changed
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 41
41
}
42
42
function calculatePositions ( ) {
43
43
positions = [ ] ;
44
- $ ( ".docs-content h3,.docs-content h4" ) . each ( function ( ) {
44
+ $ ( ".docs-content > div > h3,.docs-content > div > h4" ) . each ( function ( ) {
45
45
positions . push ( {
46
46
el : $ ( "#toc-item-" + $ ( this ) . attr ( 'id' ) ) ,
47
- pos : $ ( this ) . position ( ) . top + $ ( this ) . height ( ) + parseInt ( $ ( this ) . css ( "marginTop" ) )
47
+ orig : $ ( this ) ,
48
+ pos : $ ( this ) . offset ( ) . top + parseInt ( $ ( this ) . css ( "marginTop" ) )
48
49
} ) ;
49
50
} ) ;
50
51
}
51
52
52
53
function getCurrentItem ( ) {
54
+ if ( positions . length === 0 ) {
55
+ return ;
56
+ }
53
57
var top = $ ( window ) . scrollTop ( ) ;
54
58
var previous = positions [ 0 ] . el ;
55
59
for ( var i = 0 ; i < positions . length ; i ++ ) {
75
79
}
76
80
$ ( window ) . resize ( resizeWindow ) ;
77
81
$ ( window ) . on ( "scroll" , scrollWindow ) ;
78
-
79
- resizeWindow ( ) ;
80
- scrollWindow ( ) ;
82
+ setTimeout ( function ( ) {
83
+ resizeWindow ( ) ;
84
+ scrollWindow ( ) ;
85
+ } , 500 ) ;
81
86
82
87
} ) ;
83
88
</ script >
You can’t perform that action at this time.
0 commit comments