How to use easing in the jQuery plugin jQuery.ScrollTo?

梦想与她 提交于 2020-01-01 08:38:33

问题


The website only mentions the easing option:

# easing: Name of the easing equation.

But there's no example.

How to use this feature?


回答1:


The examples are here: http://demos.flesler.com/jquery/scrollTo/

Use like so:

$.scrollTo( '#options-examples', 800, {easing:'easeOutQuad'} );

These easing functions don't come built in though. You can use the jQuery Easing plugin. This then supplies the following easing functions:

  • jswing
  • easeInQuad
  • easeOutQuad
  • easeInOutQuad
  • easeInCubic
  • easeOutCubic
  • easeInOutCubic
  • easeInQuart
  • easeOutQuart
  • easeInOutQuart
  • easeInQuint
  • easeOutQuint
  • easeInOutQuint
  • easeInSine
  • easeOutSine
  • easeInOutSine
  • easeInExpo
  • easeOutExpo
  • easeInOutExpo
  • easeInCirc
  • easeOutCirc
  • easeInOutCirc
  • easeInElastic
  • easeOutElastic
  • easeInOutElastic
  • easeInBack
  • easeOutBack
  • easeInOutBack
  • easeInBounce
  • easeOutBounce
  • easeInOutBounce



回答2:


You can find the default usage here: http://gsgd.co.uk/sandbox/jquery/easing/

Here is an example of 'easeOutQuad':

function (){
 jQuery.easing.def = 'easeOutQuad';

 $('#options-examples').on('click','a', function() {
   $('#another-option-examples').slideToggle(1000);
   return false;
 });
}


来源:https://stackoverflow.com/questions/4710438/how-to-use-easing-in-the-jquery-plugin-jquery-scrollto

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!