diff options
| author | Eltrac <hi@guhub.cn> | 2025-09-16 14:58:24 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-09-16 14:58:24 +0800 |
| commit | 788a3d9c1965bbba1ba793732a054d1b0d898a4e (patch) | |
| tree | 443afb39b9f762a3bfed1f35c4d8d09a13cd5f8c /src | |
| parent | 7eb322e84a1fc56308614f51342392dbf4135286 (diff) | |
refactor: rename open/closeLightBox methods shortly
Diffstat (limited to 'src')
| -rw-r--r-- | src/lightbox.js | 10 |
1 files changed, 5 insertions, 5 deletions
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(); } |
