PhotoSwipe icon indicating copy to clipboard operation
PhotoSwipe copied to clipboard

Fix shadow DOM: Change target for event

Open AlyonaCh opened this issue 1 year ago • 3 comments

Fix #2096 . I changed target for event. It works for me.

AlyonaCh avatar Apr 10 '24 11:04 AlyonaCh

I'll look into it, this may potentially cause the event to not fire in older mobile browsers. If you have a test case with the Shadow DOM (from #2096) - please provide a link or source.

dimsemenov avatar Apr 11 '24 09:04 dimsemenov

The issue with your solution is that if a pointer is released outside of the document - the pointerup/cancel event is not fired.

This can be solved via setPointerCapture, however, it modifies event.target and makes it always the initial element, which messes up click/tap/doubletap event handling.

A similar thing happens if legacy mouse and touch events are used (mouseup, touchend etc), however, they don't have an alternative to setPointerCapture. So using setPointerCapture would also mean dropping full support for non-pointer events.

A possible solution might be to listen for pointerleave and cancel all gestures if it is triggered, but it needs testing.

I'm not sure yet what's the best approach to solve this yet, just posting the findings.

dimsemenov avatar Apr 15 '24 05:04 dimsemenov

I made a demo repo reproducing the problem: https://github.com/AlyonaCh/ShadowDOMExample https://alyonach.github.io/ShadowDOMExample/

AlyonaCh avatar May 27 '24 10:05 AlyonaCh