Last active
August 29, 2015 14:05
-
-
Save flexbox/d2d20cd49780feb0e43f to your computer and use it in GitHub Desktop.
Show / hide magellan expedition in page. See the demo http://tallwave.com/
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
.is-hidden { | |
display:none; | |
} |
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
$(window).scroll(function(){ | |
// Get container scroll position | |
var fromTop = $(this).scrollTop() + topMenuHeight; | |
//Check if we should be showing magellan or not | |
if($('[data-magellan-expedition]').length >0){ | |
var lastBottomOffset = $('[data-magellan-destination]').last().offset().top + $('[data-magellan-destination]').last().outerHeight(); | |
if(fromTop>lastBottomOffset){ | |
$('[data-magellan-expedition]').addClass('is-hidden'); | |
} else{ | |
$('[data-magellan-expedition]').removeClass('is-hidden'); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment