annotate src/DML/VendorAssetsBundle/Resources/assets/jquery.scroll-to/dev/jquery.scroll-to.js @ 1:f38015048f48 tip

Added GPL
author Daniel Wolff
date Sat, 13 Feb 2016 20:43:38 +0100
parents 493bcb69166c
children
rev   line source
Daniel@0 1 /*!
Daniel@0 2 * lions-mark.com/jquery/scrollTo/
Daniel@0 3 */
Daniel@0 4 $.fn.scrollTo = function( target, options, callback ){
Daniel@0 5 if(typeof options == 'function' && arguments.length == 2){ callback = options; options = target; }
Daniel@0 6 var settings = $.extend({
Daniel@0 7 scrollTarget : target,
Daniel@0 8 offsetTop : 50,
Daniel@0 9 duration : 500,
Daniel@0 10 easing : 'swing'
Daniel@0 11 }, options);
Daniel@0 12 return this.each(function(){
Daniel@0 13 var scrollPane = $(this);
Daniel@0 14 var scrollTarget = (typeof settings.scrollTarget == "number") ? settings.scrollTarget : $(settings.scrollTarget);
Daniel@0 15 var scrollY = (typeof scrollTarget == "number") ? scrollTarget : scrollTarget.offset().top + scrollPane.scrollTop() - parseInt(settings.offsetTop);
Daniel@0 16 scrollPane.animate({scrollTop : scrollY }, parseInt(settings.duration), settings.easing, function(){
Daniel@0 17 if (typeof callback == 'function') { callback.call(this); }
Daniel@0 18 });
Daniel@0 19 });
Daniel@0 20 }