Skip to content

Commit 00f8d95

Browse files
committed
fix(video): avoid video player conflicts with swipe navigation in Safari (fix #364)
1 parent 3ab1826 commit 00f8d95

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/plugins/video/VideoSlide.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export function VideoSlide({ slide, offset }: VideoSlideProps) {
9494
const scaleWidthAndHeight = () => {
9595
const scalingProps: React.ComponentProps<"video"> = {};
9696

97-
// to prevent video element overflow from its container
97+
// to prevent the video element overflow from its container
9898
scalingProps.style = { maxWidth: "100%", maxHeight: "100%" };
9999

100100
if (width && height && containerRect) {
@@ -126,6 +126,13 @@ export function VideoSlide({ slide, offset }: VideoSlideProps) {
126126
return null;
127127
};
128128

129+
// avoid conflicts with swipe navigation in Safari
130+
const stopPropagationInSafari = (event: React.PointerEvent) => {
131+
if (/^((?!chrome|android).)*(safari|mobile)/i.test(navigator.userAgent)) {
132+
event.stopPropagation();
133+
}
134+
};
135+
129136
return (
130137
<>
131138
{sources && (
@@ -167,6 +174,9 @@ export function VideoSlide({ slide, offset }: VideoSlideProps) {
167174
onEnded={() => {
168175
publish(ACTIVE_SLIDE_COMPLETE);
169176
}}
177+
onPointerUp={stopPropagationInSafari}
178+
onPointerDown={stopPropagationInSafari}
179+
onPointerMove={stopPropagationInSafari}
170180
>
171181
{sources.map(({ src, type, media }) => (
172182
<source key={[src, type, media].filter(Boolean).join("|")} src={src} type={type} media={media} />

0 commit comments

Comments
 (0)