Created
January 3, 2013 21:20
-
-
Save jrodl3r/4447397 to your computer and use it in GitHub Desktop.
Floating Scroll Title Menu
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 type="text/javascript"> | |
$(document).ready(function () { | |
// Fixed-Scroll H2 Control Menu | |
var menuYloc = parseInt($('h2.floating-title').css('top')); | |
var menuOffset = 0; | |
$(window).scroll(function () { | |
// Fixed-Scroll H2 Control Menu (Logic) | |
if ($(document).scrollTop() > 200) | |
menuOffset = (menuYloc + $(document).scrollTop() - 240) + 'px'; | |
else | |
menuOffset = (menuYloc + $(document).scrollTop()) + 'px'; | |
if ($(document).scrollTop() >= 240) | |
$('h2.floating-title').addClass('pg-scrolled'); | |
else if ($(document).scrollTop() < 200) | |
$('h2.floating-title').removeClass('pg-scrolled'); | |
// Inject Return-to-Top Link | |
if ($(document).scrollTop() >= 800) { | |
if(!$('#return-to-top').length) | |
$("#floating-controller").append('<a id="return-to-top" href="#wrapper">Return to top</a>'); | |
} else | |
$('#return-to-top').remove(); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment