bug? prev/next function
Hi,
here is a project: http://dev2.infotechnology.hu/galeria You can zoom-in on pictures... There are the slide arrow buttons. If youclick on them will work fine. if you use keyup (left/right buttons) ... Works fine..
But...After when you close the "zoomed" container... itt will destroye the cycle styles:
function closeClick() {
$("#onfucus").fadeOut(300);
$("#galeria-kepek-container").fadeOut(300, function () {
$.when($('#kepek-cycle').cycle('destroy')).then(function ( ) {
setImgStyle(); //reset the the original styles
});
});
}
After distoryed: When you use arrowkeys the picture jump over the next pic in the container, after slide one more.. The click function remain good!
Check it, please !
$(document.documentElement).keyup(function (event) {
if (event.keyCode == 37) {
$("#kepek-cycle").cycle('prev');
} else if (event.keyCode == 39) {
$("#kepek-cycle").cycle('next');
}
});
You're attaching a listener to the keyup event every time you open a gallery (i.e.: if you open a fifth gallery, your left/right code executes 5 times). You must remove the listener when you close the gallery. Add:
function handleKeyUp(event) {
if (event.keyCode == 37) {
$("#kepek-cycle").cycle('prev');
} else if (event.keyCode == 39) {
$("#kepek-cycle").cycle('next');
}
}
$(document.documentElement).on('keyup', handleKeyUp);
function closeClick(){
...
$(document.documentElement).off('keyup', handleKeyUp);
}