解除绑定/重新绑定。对()从动画按钮/。关闭()鼠标事件 [英] Unbinding/Rebinding .on()/.off() mouse events from animated buttons
问题描述
此问题是主题相关的另外一个我以前公布。我正在做一个新的问题的原因是因为我改变的东西了一下,自那时以来,一直无法处理豆蔻问题。
This question is somehow related to one other I posted before. The reason I'm making a new question is because I changed things a bit and haven't been able to deal with a litte issue since then.
所以,我有这个简单的横向幻灯片。我有一个左,右按键来控制它(除了直接点击幻灯片的能力)。基本上,我希望我的按钮时,幻灯片即它的左/右月底关闭自己,当他们再次nedded激活。我试着.off(),但它只是停用permanentely。当我想回去的 - 。对() - 这是行不通的。
So, I have this simple horizontal slideshow. I have a left and right button to control it (besides the ability to directly click on the slides). Basically I want my buttons to deactivate themselves when the slideshow reaches it's left/right end and reactivate when they are nedded again. I've tried with .off() but it just deactivates permanentely. When I want it back on - .on() - it doesn't work.
HTML标记:
<div id="rocksMenu_btnLeft"></div>
<div id="rocksMenu_btnRight"></div>
<div id="centerArea">
<div id="menuContainer">
<div id="menuItem_1" class="menuItem">
<div class="content">Contents1</div>
</div>
<div id="menuItem_2" class="menuItem">
<div class="content">Contents2</div>
</div>
<div id="menuItem_3" class="menuItem">
<div class="content">Contents3</div>
</div>
<div id="menuItem_4" class="menuItem">
<div class="content">Contents4</div>
</div>
</div>
</div>
在这里全部code - 小提琴(干净的版本 - 我删除了禁用按钮code尝试,因为它是越来越乱)。
我搜索了这个问题,但未能得到明确的答案。
Full code here - Fiddle (clean version - I deleted my button disabling code try, because it was getting messy). I've searched for this issue, but couldn't get a clear answer.
感谢名单。
佩德罗
推荐答案
您不必停用事件,只是做一个检查,如果达到了目的,不要做动画的动作。
You don't have to deactivate the event, just do a check and if the end is reached, don't do the animation action.
$('#rocksMenu_btnRight').on('click', function() {
if (menuItem_place === menuItem_limit) return;
// animation code
}
有关 btnLeft
只是改变了条件如果(menuItem_place === 0)回报;
这篇关于解除绑定/重新绑定。对()从动画按钮/。关闭()鼠标事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!