Last active
October 6, 2016 19:17
-
-
Save srikat/8681944 to your computer and use it in GitHub Desktop.
Using Waypoints Sticky Elements to fix elements to top of page upon scrolling in WordPress. http://sridharkatakam.com/using-waypoints-sticky-elements-fix-elements-top-page-upon-scrolling-wordpress/
This file contains hidden or 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', 'stick_elements' ); | |
function stick_elements() { | |
wp_enqueue_script( 'waypoints', get_stylesheet_directory_uri() . '/js/waypoints.min.js', array( 'jquery' ), '1.0.0' ); | |
wp_enqueue_script( 'waypoints-sticky', get_stylesheet_directory_uri() .'/js/waypoints-sticky.min.js' , array( 'waypoints' ), '1.0.0' ); | |
wp_enqueue_script( 'waypoints-sticky-init', get_stylesheet_directory_uri() .'/js/waypoints-sticky-init.js' , array( 'waypoints-sticky' ), '1.0.0' ); | |
} |
This file contains hidden or 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
/* Sticky Tagline section at viewport widths 600px and above in Minimum Pro | |
---------------------------------------------------------------------------- */ | |
@media only screen and (min-width: 600px) { | |
.minimum .site-tagline.stuck { | |
position: fixed; | |
width: 100%; | |
top: 62px; | |
margin-top: 0; | |
} | |
.admin-bar .site-tagline.stuck { | |
top: 90px; | |
} | |
.site-tagline.stuck { | |
position: fixed; | |
width: 100%; | |
top: 62px; | |
margin-top: 0; | |
} | |
} |
This file contains hidden or 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
/* Sticky Primary Nav at viewport widths 600px and above | |
----------------------------------------------------------- */ | |
@media only screen and (min-width: 600px) { | |
.nav-primary.stuck { | |
position: fixed; | |
width: 100%; | |
top: 0; | |
} | |
.admin-bar .nav-primary.stuck { | |
top: 28px; | |
} | |
} |
This file contains hidden or 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(document).ready(function($) { | |
$('.nav-primary').waypoint('sticky'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment