Make WordPress Core

Ticket #29979: twenty-fifteen.2.php

File twenty-fifteen.2.php, 949 bytes (added by MikeHansenMe, 12 years ago)

A few small changes. Should reach the bottom now of a long scrollbar.

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_scrollheight = $( '#sidebar' )[0].scrollHeight;
13 var content_scrollheight = $( '#content' )[0].scrollHeight;
14 var ratio = sidebar_scrollheight / content_scrollheight;
15 var window_height = $( window ).height();
16 var offset = content_scrollheight - window_height;
17 var multiplier = content_scrollheight / offset;
18
19 $( window ).scroll( function() {
20 var content_position = $( window ).scrollTop();
21 var sidebar_position = Math.round( content_position * ratio * multiplier );
22 $( '#sidebar' ).scrollTop( Math.abs( sidebar_position ) );
23 } );
24 } );
25 </script>
26 <?php
27}
28add_action( 'wp_head', 'tf_script' );
29
30
31function tf_add_jquery() {
32 wp_enqueue_script( 'jquery' );
33}
34add_action( 'wp_enqueue_scripts', 'tf_add_jquery' );