| (function($){ |
| $.fn.scrollingTo = function( opts ) { |
| var defaults = { |
| animationTime : 1000, |
| easing : '', |
| callbackBeforeTransition : function(){}, |
| callbackAfterTransition : function(){} |
| }; |
| |
| var config = $.extend( {}, defaults, opts ); |
| |
| $(this).click(function(e){ |
| var eventVal = e; |
| e.preventDefault(); |
| |
| var $section = $(document).find( $(this).data('row') ); |
| if ( $section.length < 1 ) { |
| return false; |
| }; |
| |
| if ( $('html, body').is(':animated') ) { |
| $('html, body').stop( true, true ); |
| }; |
| |
| var scrollPos = $section.offset().top; |
| |
| if ( $(window).scrollTop() == scrollPos ) { |
| return false; |
| }; |
| |
| config.callbackBeforeTransition(eventVal, $section); |
| |
| $('html, body').animate({ |
| 'scrollTop' : ((scrollPos-100)+'px' ) |
| }, config.animationTime, config.easing, function(){ |
| config.callbackAfterTransition(eventVal, $section); |
| }); |
| }); |
| }; |
| }(jQuery)); |