Skip to content

Instantly share code, notes, and snippets.

@markng
Created August 15, 2011 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markng/1148062 to your computer and use it in GitHub Desktop.
Save markng/1148062 to your computer and use it in GitHub Desktop.
aside scroller.js
jQuery(document).ready(function() {
var triggers_in_viewport = [];
checkTriggers();
$(window).scroll(function(event) {
checkTriggers();
});
$('aside h3 a').click(function(event) {
showAside($(this).attr('href'));
});
function showAside (aside_name) {
$('aside ul li div').hide();
$('a[href="'+aside_name+'"]').parent().parent().find('div').show();
}
function checkTriggers () {
triggers_in_viewport = $("a.aside_trigger:in-viewport");
showAside('#'+$(triggers_in_viewport[0]).attr('name'));
}
});
@markng
Copy link
Author

markng commented Aug 15, 2011

This will need the viewport jquery plugin.

@markng
Copy link
Author

markng commented Aug 15, 2011

Download the one from here : https://github.com/NV/jquery_viewport - that's what I tested it with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment