Last active
November 30, 2017 09:03
-
-
Save fiximportant/82f446f18e9d927e50ce06e348065e36 to your computer and use it in GitHub Desktop.
JS Sticky
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
<script> | |
$(function(){ | |
//begin title fixed | |
$(document).load($(window).bind("resize", listenWidth)); | |
function listenWidth( e ) { | |
var windowWidth = $(window).width(); | |
if (windowWidth > 767) { | |
stick(); | |
} | |
else { | |
unstick(); | |
} | |
} | |
listenWidth(); // Add this here to execute the funtion onload. | |
//init always | |
$('.js-sticky-menu').sticky( | |
{ | |
topSpacing:0, | |
zIndex: 999, | |
className: 'is-sticky', | |
wrapperClassName: 'b-wrapper-sticky', | |
responsiveWidth: true, | |
} | |
); | |
//on stick | |
function stick() { | |
$('.js-sticky-title').sticky( | |
{ | |
topSpacing:50, | |
zIndex: 999, | |
className: 'is-sticky', | |
wrapperClassName: 'b-wrapper-sticky', | |
responsiveWidth: true, | |
} | |
); | |
}//end stick | |
//off stick | |
function unstick() { | |
$('.js-sticky-title').unstick(); | |
}//end unstick | |
//end title fixed | |
});//END READY | |
</script> | |
<div class="b-title js-sticky-title">Title</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment