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

前端 未结 2 1658
后悔当初
后悔当初 2021-02-19 22:35

The website only mentions the easing option:

# easing: Name of the easing equation.

But there\'s no example.

How to use this feature?

相关标签:
2条回答
  • 2021-02-19 22:59

    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
    0 讨论(0)
  • 2021-02-19 22:59

    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;
     });
    }
    
    0 讨论(0)
提交回复
热议问题