-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
33 lines (19 loc) · 947 Bytes
/
Copy pathscripts.js
File metadata and controls
33 lines (19 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*jshint browser: true, devel: true, debug: true */
(function( window, document, undefined ) {
var activePage, position, sidebar,
narrowScreen = ( window.getComputedStyle( document.body, ':after' ).getPropertyValue( 'content' ) === 'narrow' ) ? true : false
// if it's not the index page and not a narrow screen
if ( window.location.pathname.length && !narrowScreen ) {
// get the sidebar
sidebar = document.getElementById( 'sidebar' )
// query the dom for the active page
activePage = document.getElementsByClassName( 'page-active' )
// if an active page was found
if ( activePage.length ) {
// get the offset position and give a padding of 80px
position = activePage[0].offsetTop - 80
// set the scroll position of the sidebar to the new position
sidebar.scrollTop = position
}
}
})( window, document )