Skip to content

Instantly share code, notes, and snippets.

@iaian
Last active August 29, 2015 14:20
Show Gist options
  • Save iaian/b53af861e6a723433946 to your computer and use it in GitHub Desktop.
Save iaian/b53af861e6a723433946 to your computer and use it in GitHub Desktop.
Smooth anchor scroll and hide reveal for services / pricing
$(function() {
// Smooth anchor scroll
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
// Services / Pricing
$('#subnav a').click(function(e) {
var revealClass = $(this).attr('data-reveal-class'),
$servicesContainer = $('.services-content');
if (revealClass.length > 0) {
e.preventDefault();
$servicesContainer.find('.services-text').each(function() {
if (! $(this).hasClass(revealClass)) {
$(this).fadeOut();
} else {
$(this).fadeIn();
}
});
}
});
});
@iaian
Copy link
Author

iaian commented May 11, 2015

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