Bouncy ball of love

This commit is contained in:
John O'Nolan
2014-07-22 13:21:33 +02:00
parent 5dc787d572
commit 00eca81a1e
3 changed files with 126 additions and 10 deletions

View File

@ -26,6 +26,8 @@
casperFullImg();
$(window).smartresize(casperFullImg);
$(".scroll-down").arctic_scroll();
});
}(jQuery));
@ -56,4 +58,33 @@
// smartresize
jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };
})(jQuery,'smartresize');
})(jQuery,'smartresize');
// Arctic Scroll by Paul Adam Davis
// https://github.com/PaulAdamDavis/Arctic-Scroll
(function ($) {
$.fn.arctic_scroll = function (options) {
var defaults = {
elem: $(this),
speed: 500
};
var options = $.extend(defaults, options);
options.elem.click(function(event){
event.preventDefault();
var offset = ($(this).attr('data-offset')) ? $(this).attr('data-offset') : false,
position = ($(this).attr('data-position')) ? $(this).attr('data-position') : false;
if (offset) {
var toMove = parseInt(offset);
$('html,body').stop(true, false).animate({scrollTop: ($(this.hash).offset().top + toMove) }, options.speed);
} else if (position) {
var toMove = parseInt(position);
$('html,body').stop(true, false).animate({scrollTop: toMove }, options.speed);
} else {
$('html,body').stop(true, false).animate({scrollTop: ($(this.hash).offset().top) }, options.speed);
}
});
};
})(jQuery);