From 788a3d9c1965bbba1ba793732a054d1b0d898a4e Mon Sep 17 00:00:00 2001 From: Eltrac Date: Tue, 16 Sep 2025 14:58:24 +0800 Subject: refactor: rename open/closeLightBox methods shortly --- src/lightbox.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/lightbox.js') diff --git a/src/lightbox.js b/src/lightbox.js index d21b7ab..49884cc 100644 --- a/src/lightbox.js +++ b/src/lightbox.js @@ -30,7 +30,7 @@ export default class LightBox { this.images.forEach(image => { if (image.tagName !== 'IMG') return; image.id = crypto.randomUUID(); // generate unique id for each image - image.addEventListener('click', () => this.openLightBox(image)); // click image to open lightbox + image.addEventListener('click', () => this.open(image)); // click image to open lightbox }); } @@ -53,7 +53,7 @@ export default class LightBox { * ============ */ - openLightBox(image) { + open(image) { // hide and store original image image.style.visibility = 'hidden'; this.currentImage = image; @@ -71,7 +71,7 @@ export default class LightBox { this.overlay.show(); } - closeLightBox(image) { + close(image) { // show and unstore original image image.style.visibility = 'visible'; this.currentImage = null; @@ -86,12 +86,12 @@ export default class LightBox { closeCurrent() { if (!this.currentImage) return; - this.closeLightBox(this.currentImage); + this.close(this.currentImage); } closeAll() { this.images.forEach(image => { - this.closeLightBox(image); + this.close(image); }); this.overlay.hide(); } -- cgit v1.2.3