延迟jQuery切换Class效果,直到幻灯片动画完成
Delaying jQuery toggleClass effect until a slide animation has finished
我在使用jQueryDelay()函数时遇到了一些问题。我目前正在使用它来尝试并强制toggleClass操作等待,直到我的一个div上的slideUp动画完成,但它似乎不起作用。
我的风格旨在拥有一个圆角条,当点击时,它会扩展以显示更多内容,底部条的圆角会变为方形,看起来好像条实际上已经扩展以显示内容。这很好,但它可以工作,当我折叠展开时,在折叠动画完成后,栏需要回到底部有圆角。目前,它似乎在这部动画完成之前就已经启动了。
我在网上读到jQuery的"慢速"转换速度是600毫秒,我将延迟设置为800以确保它不会妨碍运行,但这实际上并没有起到任何作用。
有什么建议吗?下面的代码和小提琴:
$(function() {
$('span.history_record_toggle').click(function () {
if($(this).hasClass('collapsed')){
$(this).text('Show +');
$(this).toggleClass('collapsed');
$(this)
.closest('.history_record_container')
.find('.history_record_body')
.slideUp('slow',function() {
});
$(this)
.parent()
.toggleClass('squared_bottom');
}else{
$(this).text('Hide -');
$(this).toggleClass('collapsed');
$(this)
.closest('.history_record_container')
.find('.history_record_body')
.slideDown('slow',function() {
});
$(this)
.parent()
.delay(800)
.toggleClass('squared_bottom');
};
});
});
http://jsfiddle.net/jezzipin/KFeHd/6/
jQuery动画和效果具有回调函数,用于在它完成后进行的操作。
例如
var thisParent = $(this).parent();
$(this).closest('.history_record_container').find('.history_record_body').slideDown('slow',function() {
$(thisParent).toggleClass('squared_bottom');
});
试试这个:在这里摆弄
$(function() {
$('span.history_record_toggle').click(function () {
$zis = $(this);
if($zis.hasClass('collapsed')){
$zis.text('Show +')
.removeClass('collapsed')
.closest('.history_record_container')
.find('.history_record_body')
.slideUp('slow',function() {
$zis.parent().removeClass('squared_bottom');
});
$zis.parent().addClass('squared_bottom');
}else{
$zis.text('Hide -')
.addClass('collapsed')
.closest('.history_record_container')
.find('.history_record_body')
.slideDown('slow',function() {
});
$zis.parent().addClass('squared_bottom');
};
});
});
相关文章:
- jQuery透明图像描述鼠标悬停时的幻灯片动画
- jquery图片库幻灯片动画
- 选择2.js和jQuery幻灯片动画滞后/抖动
- 如何在显示隐藏元素时在 JQuery 中制作幻灯片动画
- 画布幻灯片动画
- JQuery WOW幻灯片/动画效果:Z指数问题
- 延迟jQuery切换Class效果,直到幻灯片动画完成
- Javascript:悬停时滞后;制作幻灯片动画
- 幻灯片动画未定义
- 点击按钮触发jQuery幻灯片动画
- 为什么我的背景幻灯片动画在更改之间有延迟
- 带有幻灯片动画的可关闭底部栏
- jquery的幻灯片动画;工作不正常
- JQuery垂直幻灯片动画不会移动
- 为jquery幻灯片动画添加不透明度效果
- 向ng重复添加幻灯片动画
- 如何防止引导转盘在单击右/左控件后恢复幻灯片动画
- 单击时水平播放幻灯片动画
- Jbgallery 3.0幻灯片动画是否有可能从白色淡出
- jQuery:幻灯片动画走得很远,然后“跳”到正确的高度