Make WordPress Core

Ticket #29979: twenty-fifteen.php

File twenty-fifteen.php, 751 bytes (added by MikeHansenMe, 12 years ago)
Line 
1<?php
2/*
3Plugin Name: Twenty Fifteen Scroll
4*/
5
6function tf_script() {
7 ?>
8 <script type="text/javascript">
9 jQuery( document ).ready( function ( $ ) {
10 $( '#sidebar' ).css( 'overflow', 'hidden' );
11
12 var sidebar_height = $( '#sidebar' )[0].scrollHeight; //608
13 var content_height = $( '#content' )[0].scrollHeight; //582
14 var ratio = sidebar_height / content_height;
15
16 $( window ).scroll( function() {
17 var content_position = $( window ).scrollTop();
18 var sidebar_position = content_position * ratio;
19 $( '#sidebar' ).scrollTop( sidebar_position );
20 } );
21 } );
22 </script>
23 <?php
24}
25add_action( 'wp_head', 'tf_script' );
26
27
28function tf_add_jquery() {
29 wp_enqueue_script( 'jquery' );
30}
31add_action( 'wp_enqueue_scripts', 'tf_add_jquery' );