Javascript cbp全宽滑块的键盘导航
我试过了,但没有成功。有人能帮忙吗,如何为这个滑块启用键盘导航Javascript cbp全宽滑块的键盘导航,javascript,jquery,css,slider,keyboard-navigation,Javascript,Jquery,Css,Slider,Keyboard Navigation,我试过了,但没有成功。有人能帮忙吗,如何为这个滑块启用键盘导航 _toggleNavControls : function() { // if the current item is the first one in the list, the left arrow is not shown // if the current item is the last one in the list, the right arrow is not shown
_toggleNavControls : function() {
// if the current item is the first one in the list, the left arrow is not shown
// if the current item is the last one in the list, the right arrow is not shown
switch( this.current ) {
case 0 : this.$navNext.show(); this.$navPrev.hide(); break;
case this.itemsCount - 1 : this.$navNext.hide(); this.$navPrev.show(); break;
default : this.$navNext.show(); this.$navPrev.show(); break;
}
// highlight navigation dot
this.$navDots.eq( this.old ).removeClass( 'cbp-fwcurrent' ).end().eq( this.current ).addClass( 'cbp-fwcurrent' );
}
任何帮助都将不胜感激。
您需要在_initEvents函数中绑定文档上的keydown事件,并观察左右箭头键是否被按下:
$(document).keydown(keyHandler);
function keyHandler(event) {
if (event.keyCode === 39) {
if(self.$navNext.is(":visible")) self.$navNext.trigger("click.cbpFWSlider");
return false;
} else if (event.keyCode === 37) {
if(self.$navPrev.is(":visible")) self.$navPrev.trigger("click.cbpFWSlider");
return false;
}
};
注意:在JSFIDLE中,不要忘了点击预览区域的右下角,将焦点放在预览区域中,这样就可以看到关键点 你说的键盘导航是什么意思?你想用键盘上的箭头来控制滑块吗?当然!我想用键盘和鼠标控制幻灯片@阿纳斯·奥马尔