PhotoSwipe icon indicating copy to clipboard operation
PhotoSwipe copied to clipboard

Shadow DOM problems

Open AlyonaCh opened this issue 1 year ago • 0 comments

When using PhotoSwipe inside a shadow root, zoom functionality fails when clicking on an image, and closing the gallery fails when clicking on the background. This issue arises because the event is attached to the window using "events.add(window)". Consequently, the event's target becomes the host element of the shadow root, rather than the element clicked by the user. This leads to the problem because PhotoSwipe relies on the presence of classes like 'pswp__img', 'pswp__item', 'pswp__zoom-wrap' when processing a click, which the host element lacks. The solution lies in attaching the event not to the window, but to an element within the shadow root. Is it possible to specify the element to which events are attached in the options?

AlyonaCh avatar Apr 08 '24 05:04 AlyonaCh