Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v5-beta: Allow passing an Element instead of gallerySelector #1812

Closed
tobyzerner opened this issue Sep 6, 2021 · 3 comments
Closed

v5-beta: Allow passing an Element instead of gallerySelector #1812

tobyzerner opened this issue Sep 6, 2021 · 3 comments

Comments

@tobyzerner
Copy link
Contributor

tobyzerner commented Sep 6, 2021

I already have a reference to the Element I want to use for the gallery, and it would be much easier to be able to just pass this into the lightbox options rather than have to assign it an ID to select.

I think the ideal API for the options would look like this:

type Options = {
    // If string, convert into a NodeList via document.querySelectorAll
    gallery: string | Element | NodeList | Array;
    children: string | Element | NodeList | Array;
};

// example
new PhotoSwipeLightbox({
    gallery: myGalleryElement,
    children: 'a',
    pswpModule: PhotoSwipe
});

I'd be happy to do a PR if this is a change you would welcome.

@dimsemenov
Copy link
Owner

I like this idea, it does make sense.

Maybe the naming of properties gallery and children can be improved somehow as well.

@tobyzerner
Copy link
Contributor Author

I've just done a PR - #1813. Let me know if you have any other suggestions for the naming and I can update it – as well as the docs.

@dimsemenov
Copy link
Owner

Thank you, I pushed it to 5.1.3. Will update the docs too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants