开发者

Stop keydown scrolling from bubbling

开发者 https://www.devze.com 2023-03-08 02:20 出处:网络
I\'m trying to make a slider which goes left and right with the keydown function and replaces a div with content specific to each li. However when yo开发者_高级运维u press the keys too fast in success

I'm trying to make a slider which goes left and right with the keydown function and replaces a div with content specific to each li. However when yo开发者_高级运维u press the keys too fast in succession then sometimes content either doesn't show or repeats itself as well as the events bubbling up. I've tried a few methods but nothing really works. The URL is http://jackjamesmartin.ninoharris.com/


var wait = false;
function theEvent(){
   if(wait){
     return;
   }
   wait = true;

   do somthing

   //You need to make sure that this is in the callbacks, ie all events are complete.
   wait = false;

  // or setTimeout(function(){wait = false}, xxx )
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号