File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
guides/assets/javascripts Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 23
23
for ( var i = 0 ; i < array . length ; i ++ ) callback ( array [ i ] ) ;
24
24
}
25
25
26
- document . addEventListener ( "turbo:load" , function ( ) {
26
+ document . addEventListener ( "turbo:load" , function ( turbo_load_event ) {
27
27
var guidesMenu = document . getElementById ( "guidesMenu" ) ;
28
28
var guides = document . getElementById ( "guides" ) ;
29
29
158
158
159
159
var PAGE_LOAD_BUFFER = 1000 ;
160
160
161
+ var isDirectlyVisited = function ( ) {
162
+ return Object . keys ( turbo_load_event . detail . timing ) . length === 0 ;
163
+ }
164
+
161
165
var navHighlight = function ( entries ) {
162
166
entries . forEach ( function ( entry ) {
163
167
if ( entry . isIntersecting ) {
164
168
updateHighlight ( matchingNavLink ( entry . target ) ) ;
165
- } else if ( entry . time >= PAGE_LOAD_BUFFER && belowBottomHalf ( entry ) ) {
169
+ } else if ( isDirectlyVisited ( ) && entry . time >= PAGE_LOAD_BUFFER && belowBottomHalf ( entry ) ) {
166
170
updateHighlight ( matchingNavLink ( prevElem ( entry . target ) ) ) ;
167
171
}
168
172
} ) ;
You can’t perform that action at this time.
0 commit comments