1

I have the same question as lightbox-0.5 jquery compatibility issue

Basically I'm using jQuery Lightbox, and I have a gallery. If I click on a picture the first time and I press the -> arrow key, it goes to the next one. But if I close it and reopen, when I press the -> arrow key it skips one. And if I close it and reopen it, it skips two. And so on. If you guys wanna see the code it's here: http://pastebin.com/pAigYDCj

2 Answers 2

3

I solved the problem this way: in the method _set_image_to_view() add the line _disable_keyboard_navigation(); between lines _resize_container_image_box(objImagePreloader.width,objImagePreloader.height);

and

objImagePreloader.onload=function(){};

Thus the entire method is as follows:

function _set_image_to_view() { // show the loading // Show the loading $('#lightbox-loading').show(); if ( settings.fixedNavigation ) { $('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide(); } else { // Hide some elements $('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide(); } // Image preload process var objImagePreloader = new Image(); objImagePreloader.onload = function() { $('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]); // Perfomance an effect in the image container resizing it _resize_container_image_box(objImagePreloader.width,objImagePreloader.height); // for reducing problem with navigation using keyboard (switching some pic at one time) _disable_keyboard_navigation(); // clear onLoad, IE behaves irratically with animated gifs otherwise objImagePreloader.onload=function(){}; }; objImagePreloader.src = settings.imageArray[settings.activeImage][0]; }; 
Sign up to request clarification or add additional context in comments.

Comments

2

I've been dealing with similar problem a moment ago. Only number of skipped images was random. However I found a solution that worked for me.

Try modifying _keybord_action function in lightbox.js like this:

function _keyboard_action(objEvent) { // To ie if ( objEvent == null ) { keycode = event.keyCode; escapeKey = 27; // To Mozilla } else { keycode = objEvent.keyCode; escapeKey = objEvent.DOM_VK_ESCAPE; } // Get the key in lower case form key = String.fromCharCode(keycode).toLowerCase(); // Verify the keys to close the ligthBox if ( ( key == settings.keyToClose ) || ( key == 'x' ) || ( keycode == escapeKey ) ) { _finish(); } // Verify the key to show the previous image if ( ( key == settings.keyToPrev ) || ( keycode == 37 ) ) { // If we´re not showing the first image, call the previous if ( settings.activeImage != 0 ) { _disable_keyboard_navigation(); settings.activeImage = settings.activeImage - 1; _set_image_to_view(); } } // Verify the key to show the next image if ( ( key == settings.keyToNext ) || ( keycode == 39 ) ) { // If we´re not showing the last image, call the next if ( settings.activeImage != ( settings.imageArray.length - 1 ) ) { _disable_keyboard_navigation(); settings.activeImage = settings.activeImage + 1; _set_image_to_view(); } } } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.