| 1 | jQuery( document ).ready( function ( $ ) { |
| 2 | |
| 3 | var window_height = $( window ).height(); |
| 4 | var sidebar_scrollheight = $( '#sidebar' )[0].scrollHeight; |
| 5 | |
| 6 | if( $( '#content' ).height() < window_height && sidebar_scrollheight > window_height ) { |
| 7 | $( '#content' ).height( $( '#sidebar' ).height() ); |
| 8 | } |
| 9 | |
| 10 | var content_scrollheight = $( '#content' )[0].scrollHeight; |
| 11 | var ratio = sidebar_scrollheight / content_scrollheight; |
| 12 | var offset = content_scrollheight - window_height; |
| 13 | var multiplier = content_scrollheight / offset; |
| 14 | |
| 15 | if( $( window ).width() > 967 ) { |
| 16 | $( '#sidebar' ).css( 'overflow', 'hidden' ); |
| 17 | if( sidebar_scrollheight > window_height ) { |
| 18 | $( window ).scroll( function() { |
| 19 | var content_position = $( window ).scrollTop(); |
| 20 | var sidebar_position = ( content_position >= 0 ? Math.round( content_position * ratio * multiplier ) : 0 ); |
| 21 | $( '#sidebar' ).scrollTop( Math.abs( sidebar_position ) ); |
| 22 | } ); |
| 23 | } |
| 24 | } |
| 25 | } ); |
| 26 | No newline at end of file |