What's Changed
Full Changelog: v2.11.5...v2.12.0
Bug fixes
- Fix resize handler memory leak —
$.proxyreference mismatch caused listeners to accumulate on every open/close cycle - Fix
.lb-prevLink/.lb-nextLinkdead selectors insizeContainer()→ corrected to.lb-prev/.lb-next - Add
preloader.onerrorhandler — 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/selfinconsistency 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-describedbylinking 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 haverole="button"+tabindex="0")
New public API
lightbox.open(images, startIndex)— open programmatically with a URL string or array of{link, title, alt}objectslightbox.close()— close programmaticallylightbox.next()/lightbox.prev()— navigate programmaticallylightbox.destroy()— remove DOM elements and unbind all event listeners
New events
lightbox:open,lightbox:close,lightbox:changetriggered on$(document)with album and index data
CSS
- Switch overlay and lightbox from
position: absolutetoposition: 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 0withundefined,i = ++iwithi++ - 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 falsewithevent.preventDefault()on nav buttons - Use
selfconsistently instead of mixingself/.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