npm lightbox2 2.12.0
v2.12.0

8 hours ago

What's Changed

Full Changelog: v2.11.5...v2.12.0

Bug fixes

  • Fix resize handler memory leak — $.proxy reference mismatch caused listeners to accumulate on every open/close cycle
  • Fix .lb-prevLink/.lb-nextLink dead selectors in sizeContainer() → corrected to .lb-prev/.lb-next
  • Add preloader.onerror handler — broken images no longer leave the lightbox stuck in loading state
  • Fix SVG file type detection for URLs with query strings (image.svg?v=2) or fragments
  • Cancel pending image loads on rapid navigation — prevents race conditions causing layout glitches
  • Fix this/self inconsistency in contextmenu handler

Accessibility

  • Add role="dialog", aria-modal="true", aria-label="Image lightbox" to #lightbox
  • Implement focus trap — Tab is constrained to lightbox elements while open
  • Restore focus to the trigger element on close
  • Add aria-describedby linking the displayed image to its caption
  • Add aria-live="polite" to image counter so screen readers announce navigation
  • Remove empty href="" from nav buttons (already have role="button" + tabindex="0")

New public API

  • lightbox.open(images, startIndex) — open programmatically with a URL string or array of {link, title, alt} objects
  • lightbox.close() — close programmatically
  • lightbox.next() / lightbox.prev() — navigate programmatically
  • lightbox.destroy() — remove DOM elements and unbind all event listeners

New events

  • lightbox:open, lightbox:close, lightbox:change triggered on $(document) with album and index data

CSS

  • Switch overlay and lightbox from position: absolute to position: fixed — eliminates JS-based overlay sizing
  • Add 11 CSS custom properties for theming (colors, border radius, transition speeds) on :root
  • Remove stale -webkit-, -moz-, -o- vendor prefixes from transitions

Code quality

  • Replace void 0 with undefined, i = ++i with i++
  • Cache 7 additional jQuery element references in build() — eliminates repeated .find() calls
  • Fix selector injection in album grouping — use .filter() instead of string-concatenated selectors
  • Replace return false with event.preventDefault() on nav buttons
  • Use self consistently instead of mixing self/.bind()

Build tooling

  • Replace Bower with npm for jQuery dependency
  • Replace JSHint + JSCS with ESLint (flat config, v10)
  • Replace Grunt with npm scripts (npm run build, npm test)
  • Remove bower.json, Gruntfile.js, .jshintrc, .jscsrc
  • No global installs required — just npm install

Don't miss a new lightbox2 release

NewReleases is sending notifications on new releases.