Created
December 16, 2013 15:15
-
-
Save srikat/7988642 to your computer and use it in GitHub Desktop.
Fading away an element when scrolling down and fading it back when scrolling up in WordPress. http://sridharkatakam.com/fade-away-element-scrolling-fade-back-scrolling-wordpress/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'wp_enqueue_scripts', 'sk_enqueue_scripts' ); | |
function sk_enqueue_scripts() { | |
if ( !is_home() || !is_front_page() ) | |
return; | |
wp_enqueue_script( 'scrollTo', get_stylesheet_directory_uri() . '/js/jquery.scrollTo.min.js', array( 'jquery' ), '1.4.5-beta', true ); | |
wp_enqueue_script( 'home', get_stylesheet_directory_uri() . '/js/home.js', array( 'scrollTo' ), '', true ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function( $ ){ | |
function fade_home_top() { | |
if ( $(window).width() > 800 ) { | |
window_scroll = $(this).scrollTop(); | |
$("#home_bkgrd_image").css({ | |
'opacity' : 1-(window_scroll/300) | |
}); | |
} | |
} | |
$(window).scroll(function() { fade_home_top(); }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment