I have a problem with Fancybox 2. When Fancybox is in gallery mode and that I close the Fancybox with the focus (keyboard enter key), it moves to the second image. I can't close my Fancybox with keyboard (except ESC), it works only with mouse.
You can test this here http://jsfiddle.net/korigan/qfxZd/2/
$('.fancybox').click(function(){
focusLink = this;
}).fancybox({
beforeLoad: function() {
$('a, input, button').attr('tabIndex', -1);
$('.fancybox-overlay a, .fancybox-overlay button, .fancybox-overlayinput').attr('tabIndex', 0);
},
afterClose: function() {
focusLink.focus();
$('a, button, input').attr('tabIndex', 0);
},
});
Thanks for your help.
Fancybox has the
keys
option to set the behavior of specific pressed keys .... the default forenter
key is navigate to thenext
image of a gallery fromleft
. You can override this behavior by declaring the set of keys to move to thenext
image and omit theenter
key (numeric value =13
) so it will be removed from the stack like :Additionally, you can set the
enter
key to close fancybox within the same option like :... see JSFIDDLE