Last active
August 29, 2015 14:07
-
-
Save ramiabraham/e035eb34b237e16b84e5 to your computer and use it in GitHub Desktop.
sticky div (typically a sidebar) with compat for touch devices
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
| (function($) { | |
| $(window).bind("load", function() { | |
| var sidebar_one = $('#sidebar-1' ); | |
| var sidebar_two = $('#sidebar-2'); | |
| $( window ).scroll( function() { | |
| if ( $(this).scrollTop() > 660 && $(this).width() > 1024 ) { | |
| sidebar_one.addClass( 'fixed' ); | |
| sidebar_two.addClass( 'fixed' ); | |
| } else { | |
| sidebar_one.removeClass( 'fixed' ); | |
| sidebar_two.removeClass( 'fixed' ); | |
| } | |
| }); | |
| } ); | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment