mpetroff / pannellum

Pannellum is a lightweight, free, and open source panorama viewer for the web.
https://pannellum.org/
MIT License
4.16k stars 711 forks source link

Open URL to image as lightbox #1079

Closed Perpicx closed 2 years ago

Perpicx commented 2 years ago

I'm trying to manage to open the "info" hotspot URL to an image as lightbox. The implemented lightbox (Glightbox) is working on the page, but not on any Pannellum generated link. How can I make it work?

mpetroff commented 2 years ago

First, I'm going to assume you're using the Pannellum API and not an <iframe>, since a lightbox on the parent page wouldn't apply to the contents of an <iframe>.

As for getting it to work, it depends on when and how the lightbox library you're using hooks in to display images. You may be able to get it to work by setting attributes: {} in the hot spot configuration (along with type: "info"). This would remove the _target attribute, which could be the reason why it isn't working for you. If the lightbox library requires other attributes, you'd set them the same way. The other way would be to use the clickHandlerFunc / clickHandlerArgs hot spot configuration parameters to call the lightbox library's function to open the library directly from JavaScript.

Perpicx commented 2 years ago

I've tried the "attributes" and added the trigger class from the lightbox. It is properly showing at the a tag for the image in the source code. But nothing happens on click. I also tried a simple javascript action on click on the hotspot without success. As I said: The lightbox is working fine in the same window inside the "panorama" on a button - but ot on a hotspot.

dbwodlf3 commented 2 years ago

@Perpicx I think it have to use some trick to get something you want. use class name as id, and select the hotspot div element and do something. maybe it will works.(you can insert class to hotspot)

mpetroff commented 2 years ago

@Perpicx As I said previously, it depends on when and how the lightbox library you're using hooks in to display images. Depending on how it's implemented, it may not work on links that are dynamically added after the pages is loaded, such as what happens with hot spots.

Perpicx commented 2 years ago

Ok, I've managed it by using my own simple lightbox solution. Somehow I've overseen the "clickHandlerFunc" fucntion. Thanks anyway!