Javascript jQuery在执行debounce方法之前调用动画
我有一段代码如下:Javascript jQuery在执行debounce方法之前调用动画,javascript,jquery,jquery-plugins,throttling,debounce,Javascript,Jquery,Jquery Plugins,Throttling,Debounce,我有一段代码如下: $('.cardButton').click($.debounce(1500, function () { console.log("OK"); })); $('.cardButton').click(function(){ StartAnimationLoader(); $.debounce(1500, function () { console.log(&quo
$('.cardButton').click($.debounce(1500, function () {
console.log("OK");
}));
$('.cardButton').click(function(){
StartAnimationLoader();
$.debounce(1500, function () {
console.log("OK");
})
});
// When I execute code like this - there is nothing written in the console... - thus this method doesn't works
这种情况下的去盎司效果非常好
然而,我需要添加动画功能,这将取代“.cardButton”元素之前,去盎司发生
这样做:
$('.cardButton').click($.debounce(1500, function () {
StartAnimationLoader();
console.log("OK");
}));
// In this case - animation starts as soon as console writes out "OK" ...
或类似于以下内容:
$('.cardButton').click($.debounce(1500, function () {
console.log("OK");
}));
$('.cardButton').click(function(){
StartAnimationLoader();
$.debounce(1500, function () {
console.log("OK");
})
});
// When I execute code like this - there is nothing written in the console... - thus this method doesn't works
我需要在去抖动发生之前执行动画
我做错了什么
有人能帮我吗?向同一元素添加第二个(或更多)事件处理程序将触发两个事件(除非已停止),因此您可以通过使用两个单独的事件处理程序创建两个操作:
// existing debounce fire only after user stops clicking
$('.cardButton').click($.debounce... );
// additional event will fire on every click
$(".cardButton").click(function() { StartAnimationloader() });
有人吗给我们几分钟的时间来弄清楚你在问什么!:)您可以添加第二个事件
$('.cardButton')。单击($.debounce代码>$(.cardButton”)。单击(()=>StartAnimationloader())代码>@freedomn-m这是一段单独的代码吗?o。o@freedomn-我现在正在努力