【发布时间】:2016-01-05 09:33:50
【问题描述】:
我正在尝试禁用按钮,直到 CSS 动画结束。
负责触发点击事件的代码:
$($controls__right).on('click', function () {
replace_images();
direction = 1;
reload_content(direction);
});
动画图像的功能。在这部分代码没有执行之前,按钮应该禁用,执行后启用。
function replace_images() {
$current__images = $('.device__screen');
$current__texts = $('.text-area');
$($current__images[0].children[0]).css({
'-webkit-animation': 'scroll_down 1s',
'-moz-animation': 'scroll_down 1s',
'-ms-animation': 'scroll_down 1s',
'-o-animation': 'scroll_down 1s',
'animation': 'scroll_down 1s'
});
setTimeout(function () {
$($current__images[0].children[0]).remove();
}, 1000);
$($current__texts[0].children[0]).remove();
}
【问题讨论】:
-
写一个toggle函数来禁用/启用按钮,然后在replace_images()函数的开始和结束时调用这个函数