summaryrefslogtreecommitdiff
path: root/src/lightbox.js
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-09-17 22:03:19 +0800
committerEltrac <hi@guhub.cn>2025-09-17 22:03:19 +0800
commitfd25334f02282cba9c2cf456f99706d5589e64ee (patch)
tree1eb2eee9c828abe72ba93a9677ae4d6816a0c1b4 /src/lightbox.js
parentbca54cbb5026564b4139fe850b286239c5a54929 (diff)
refactor: new config class
Diffstat (limited to 'src/lightbox.js')
-rw-r--r--src/lightbox.js13
1 files changed, 8 insertions, 5 deletions
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