/*! * jquery.scrollto.js 0.0.1 - https://github.com/yckart/jquery.scrollto.js * scroll smooth to any element in your dom. * * copyright (c) 2012 yannick albert (http://yckart.com) * licensed under the mit license (http://www.opensource.org/licenses/mit-license.php). * 2013/02/17 **/ $.scrollto = $.fn.scrollto = function(x, y, options){ if (!(this instanceof $)) return $.fn.scrollto.apply($('html, body'), arguments); options = $.extend({}, { gap: { x: 0, y: 0 }, animation: { easing: 'swing', duration: 600, complete: $.noop, step: $.noop } }, options); return this.each(function(){ var elem = $(this); elem.stop().animate({ scrollleft: !isnan(number(x)) ? x : $(y).offset().left + options.gap.x, scrolltop: !isnan(number(y)) ? y : $(y).offset().top + options.gap.y }, options.animation); }); };