【问题标题】:jQuery animate() and easing type [duplicate]jQuery animate() 和缓动类型
【发布时间】:2016-07-11 01:18:16
【问题描述】:

我有这个:

$('h1').animate({
    //stuff to be changed,
}, {
    duration: 1000, 
    queue: false
})

当我把它改成这样的时候它不接受:

{
    duration: 1000, 
    queue: false, 
    easing: easeOutBounce
}

当提供easing 作为字符串时,我得到这个错误:

未捕获的类型错误:n.easing[this.easing] 不是函数

我应该如何放置缓动类型?

【问题讨论】:

    标签: jquery easing jquery-easing


    【解决方案1】:

    缓动应该是一个字符串,像这样:

    {
        duration: 1000,
        queue: false,
        easing: 'easeOutBounce'
    }
    

    .animate() 状态的 API 文档:

    缓动(默认:swing

    类型:字符串

    一个字符串,指示用于过渡的缓动函数。

    【讨论】:

    • 以前试过。这就出来了:Uncaught TypeError: n.easing[this.easing] is not a function
    • @Dawid 听起来您需要包含 jQueryUI 库;缓动选项不是 jQuery 的标准部分
    • @Dawid 添加jquery.ui.min.jsjquery.easing.min.js 来解决您的问题。
    • 我怎么能忘记 UI 包括非常感谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-17
    • 2012-07-30
    • 2012-06-23
    • 2015-10-28
    • 1970-01-01
    相关资源
    最近更新 更多