繁体   English   中英

jQuery不透明的动画无法正常工作

[英]jQuery animate with opacity not working

我试图在背景最初是rgba(0,0,0,0) => originalColor的div上获得闪烁效果,并使其闪烁到rgba(237,155,0,1) => noticeFlashColor 为此,我正在使用:

var noticeFlashEffect = function (applyTo, originalColor) {
    return setInterval(function () {
        $(applyTo).animate(
            { 'background-color': noticeFlashColor },
            flashTime,
            function () {
                $(applyTo).animate({ 'background-color': originalColor }, flashTime);
            }
        );
    }, (2 * flashTime));
};

但是,每次尝试执行此操作时,都会出现此错误:

未捕获的TypeError:无法读取未定义的属性“ 0”

从jQuery-ui的这一行开始:

fx.elem.style[attr] = 'rgb(' +
        Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + ',' +
        Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + ',' +
        Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ')';

但是,甚至更奇怪的是,在调试器中检查完上述变量后,上述变量似乎都不为空。

编辑:进一步的澄清:我正在使用jquery-ui.1.8.4和动画效果似乎动画时动画通知noticeFlashColor但不返回时。

看来这只是jQuery ui 1.8.4中的问题。 我升级到1.10,它似乎可以正常工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM