jquery - How to add 'easing' to animate/scrolltop -


i using following function create scroll animation anchor links:

$('a').click(function(){     $('html, body').animate(         {scrolltop: $( $.attr(this, 'href') ).offset().top},          500 );     return false; }); 

i add easing. however, when add 'easing' after '500' breaks script:

$('a').click(function(){     $('html, body').animate(         {scrolltop: $( $.attr(this, 'href') ).offset().top},          500, easing );     return false; }); 

any ideas doing wrong?

first need include jquery.ui script code should look:

$('a').click(function(){     var top = $('body').find($(this).attr('href')).offset().top;     $('html, body').animate({         scrolltop: top     },500, 'easeoutexpo');      return false; }); 

for information:

easing

the remaining parameter of .animate() string naming easing function use. easing function specifies speed @ animation progresses @ different points within animation. easing implementations in jquery library default, called swing, , 1 progresses @ constant pace, called linear. more easing functions available use of plug-ins, notably jquery ui suite.


why code not working:

  1. because use this in scope of animation method , reference body , html objects.
  2. because easing not method. string type of animation property need write string example: 'easeoutexpo' or "easeoutexpo".

Comments

Popular posts from this blog

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

Android Gson.fromJson error -