Responsive-Lightbox icon indicating copy to clipboard operation
Responsive-Lightbox copied to clipboard

Unbinding all keydown functions.

Open codesignist opened this issue 7 years ago • 0 comments

In the close function, this code unbinds all keydown events: $(document).off('keydown');

Need to describe a keyDown function:

keyDownEvent: function (e) {
    // Close lightbox with ESC
    if (e.keyCode === 27) {
        plugin.close();
    }
    // Go to next image pressing the right key
    if (e.keyCode === 39) {
        plugin.next();
    }
    // Go to previous image pressing the left key
    if (e.keyCode === 37) {
        plugin.previous();
    }
}

and need to add: $(document).on('keydown', plugin.keyDownEvent);

and to remove only this function: $(document).unbind('keydown', plugin.keyDownEvent);

codesignist avatar Sep 25 '17 13:09 codesignist