<?php
/*
Plugin Name: Twenty Fifteen Scroll
*/

function tf_script() {
	?>
	<script type="text/javascript">
	jQuery( document ).ready( function ( $ ) {
		$( '#sidebar' ).css( 'overflow', 'hidden' );
		
		var sidebar_height = $( '#sidebar' )[0].scrollHeight; //608
		var content_height = $( '#content' )[0].scrollHeight; //582
		var ratio = sidebar_height / content_height;
		
		$( window ).scroll( function() {
			var content_position = $( window ).scrollTop();
			var sidebar_position = content_position * ratio;
			$( '#sidebar' ).scrollTop( sidebar_position );
		} );
	} );
	</script>
	<?php
}
add_action( 'wp_head', 'tf_script' );


function tf_add_jquery() {
	wp_enqueue_script( 'jquery' );
}
add_action( 'wp_enqueue_scripts', 'tf_add_jquery' );
