简体   繁体   English

同时进行手风琴和变色动画

[英]Simultaneous Accordion and Colour Change Animations

I'm using jQuery 2.0.3 and jQuery UI 1.10.3 's accordion , and am trying to change the colour of the accordion panels as they open and close by doing something like this: 我正在使用jQuery 2.0.3和jQuery UI 1.10.3accordion ,我试图通过这样做来改变手风琴面板打开和关闭时的颜色:

$(".main-content").accordion({
    active: false,
    beforeActivate: function(event, ui) {
        ui.newHeader.animate({
            "background-color": "white"
        });
    },
    collapsible: true
});

I'm finding that the change is animated the first time each header is clicked, although the accordion animation waits for it to finish before starting. 虽然手风琴动画在开始之前等待它完成,但我发现在第一次点击每个标题时动画的变化是动画的。 Subsequent section activations aren't animated, although the colour change does occur. 尽管颜色发生了变化,但后续的部分激活不会动画化。

How can I make this animate at the same time as the accordion animation? 如何在手风琴动画的同时制作这个动画?

You could use css transitions to accomplish that effect. 您可以使用css过渡来实现该效果。

Working Example 工作实例

.ui-state-active {
    background: white;
    transition: background 400ms;
}
.ui-state-default {
    transition: background 400ms;
}

$(".main-content").accordion({
    active: false,
    collapsible: true
});

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

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