blueswen / mkdocs-glightbox

A MkDocs plugin supports image lightbox (zoom effect) with GLightbox.
https://blueswen.github.io/mkdocs-glightbox/
MIT License
115 stars 14 forks source link

Allow calling lightbox methods from other places #34

Closed AndBondStyle closed 2 months ago

AndBondStyle commented 4 months ago

When using mkdocs-material or instant navigation, plugin injects a script that looks like this:

document$.subscribe(() => { const lightbox = GLightbox(...); });

Instead, I suggest to insert this, making the lightbox variable accessible from outside:

const lightbox = GLightbox(...);
document$.subscribe(() => { lightbox.reload() });

This makes possible to call various methods of the lightbox instance from other JS scripts.

blueswen commented 2 months ago

LGTM! Thanks for your help.