From fd25334f02282cba9c2cf456f99706d5589e64ee Mon Sep 17 00:00:00 2001 From: Eltrac Date: Wed, 17 Sep 2025 22:03:19 +0800 Subject: refactor: new config class --- src/lightbox.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/lightbox.js') diff --git a/src/lightbox.js b/src/lightbox.js index 22cf0ff..2bd242b 100644 --- a/src/lightbox.js +++ b/src/lightbox.js @@ -1,5 +1,7 @@ -import Overlay from './overlay.js'; -import Shadow from './shadow.js'; +import Overlay from './overlay'; +import Shadow from './shadow'; +import config from './config'; +import { setConfig } from './config'; export default class LightBox { currentImage = null; @@ -11,8 +13,9 @@ export default class LightBox { * ============ */ - constructor({ selector }) { - this.selector = selector; + constructor(config) { + setConfig(config); + this.initOverlay(); this.initImages(); this.initControls(); @@ -26,7 +29,7 @@ export default class LightBox { } initImages() { - this.images = document.querySelectorAll(this.selector); + this.images = document.querySelectorAll(config.selector); this.images.forEach(image => { if (image.tagName !== 'IMG') return; image.id = crypto.randomUUID(); // generate unique id for each image -- cgit v1.2.3