lokesh / lightbox2

THE original Lightbox script (v2).
http://lokeshdhakar.com/projects/lightbox2/
MIT License
6.14k stars 1.77k forks source link

Keyboard navigation with arrows malfunctioning when Lightbox initialized multiple times #702

Open MichalRemis opened 3 years ago

MichalRemis commented 3 years ago

When lightbox is initialized multiple times (e.g. when Ajax content is loaded and lightbox needs to be reenabled), Lightbox keyboard navigation doesn't work properly - arrow keys are skipping multiple images, not just one. It's because keyboard listeners are bound multiple times when opening lightbox.

Example:

  1. go to https://lokeshdhakar.com/projects/lightbox2/ ,
  2. open console and type lightbox.init()
  3. click on FOUR IMAGE SET lightbox and try to navigate with arrows