From 8e9077ce3e2f609165a27d03c011d3cc6de27bb6 Mon Sep 17 00:00:00 2001 From: Elia Lazzari Date: Mon, 20 Feb 2023 17:45:23 +0100 Subject: [PATCH] Fixed allLensflares() functions: "toggleAllLensflares()", "showAllLensflares()" and "hideAllLensflares" --- README.md | 5 +++++ package.json | 2 +- src/index.ts | 18 ++++++++---------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f8f965d..2869971 100644 --- a/README.md +++ b/README.md @@ -228,3 +228,8 @@ const viewer = new PhotoSphereViewer.Viewer({ ### Result of the example ![multilens](https://user-images.githubusercontent.com/14907987/212864401-fa0861c7-b089-4681-b290-dce7a4a7c669.gif) + + +### CodeSandbox + +[![Edit photo-sphere-viewer-lensflare-plugin](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/photo-sphere-viewer-lensflare-plugin-2oz3zh?fontsize=14&hidenavigation=1&theme=dark) \ No newline at end of file diff --git a/package.json b/package.json index 5698c26..06d0ece 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "photo-sphere-viewer-lensflare-plugin", - "version": "1.0.5", + "version": "1.1.0", "description": "Plugin to add lens flares on a 360° pano built with photo-sphere-viewer", "main": "dist/index.js", "module": "dist/index.module.js", diff --git a/src/index.ts b/src/index.ts index a55207e..6acc0a8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -61,10 +61,8 @@ export class LensflarePlugin extends AbstractPlugin { * Toggles all lensflares */ toggleAllLensflares() { - if (this.state.visible) { - this.hideAllLensflares(); - } else { - this.showAllLensflares(); + for (const lensflare of this.getLensflares()) { + this.toggleLensflare(lensflare); } } @@ -72,18 +70,18 @@ export class LensflarePlugin extends AbstractPlugin { * Shows all lensflares */ showAllLensflares() { - this.state.visible = true; - - this.renderLensflares(); + for (const lensflare of this.getLensflares()) { + this.toggleLensflare(lensflare, true); + } } /** * Hides all lensflares */ hideAllLensflares() { - this.state.visible = false; - - this.renderLensflares(); + for (const lensflare of this.getLensflares()) { + this.toggleLensflare(lensflare, false); + } } /**