Last active
August 29, 2015 14:20
-
-
Save iaian/b53af861e6a723433946 to your computer and use it in GitHub Desktop.
Smooth anchor scroll and hide reveal for services / pricing
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
$(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(); | |
} | |
}); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
smooth scroll from : https://css-tricks.com/snippets/jquery/smooth-scrolling/