Skip to content

Instantly share code, notes, and snippets.

@srikat
Last active November 17, 2016 18:54
Show Gist options
  • Save srikat/7957483 to your computer and use it in GitHub Desktop.
Save srikat/7957483 to your computer and use it in GitHub Desktop.
Using Waypoints jQuery to animate and fade in elements as they come in focus in WordPress. http://sridharkatakam.com/using-waypoints-jquery-animate-fade-elements-scrolled-wordpress/
.home-featured .simple-social-icons ul li a.animate {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg);
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.home-featured .widget-title,
.home-featured .textwidget {
display: none;
}
add_action( 'wp_enqueue_scripts', 'include_waypoints' );
function include_waypoints() {
if ( !is_front_page() )
return;
wp_enqueue_script( 'waypoints', get_stylesheet_directory_uri() . '/js/waypoints.min.js', array( 'jquery' ), '1.0.0' );
wp_enqueue_script( 'waypoints-init', get_stylesheet_directory_uri() .'/js/waypoints-init.js' , array( 'jquery', 'waypoints' ), '1.0.0' );
}
jQuery(function($) {
$('.site-tagline').waypoint(function() {
$('.home-featured .simple-social-icons ul li a').toggleClass( 'animate' );
$('.home-featured .widget-title').fadeIn( 1500 );
$('.home-featured .textwidget').fadeIn( 3500 );
},
{
offset: '50%',
triggerOnce: true
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment