Skip to content

Instantly share code, notes, and snippets.

@adavia
Created October 5, 2017 18:02
Show Gist options
  • Select an option

  • Save adavia/6bacdd3cc288cb1ba1cf3d27e65548ee to your computer and use it in GitHub Desktop.

Select an option

Save adavia/6bacdd3cc288cb1ba1cf3d27e65548ee to your computer and use it in GitHub Desktop.
Module pattern
var Home = (function() {
var links = $("[data-behavior~=anchor-link]");
var cover = $('.cover');
var init = function() {
$(window).on("load", coverFadeOut);
}
var coverFadeOut = function() {
cover.fadeOut(1000, function() {
$(this).remove();
});
}
var scrollDown = function() {
links.click(animateScroll);
}
var animateScroll = function(event) {
if ($(this.hash)) {
$('html, body').animate({
scrollTop: $(this.hash).offset().top
}, 500);
}
};
return {
init: init,
scroll: scrollDown
};
})();
Home.init();
Home.scroll();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment