From bcb3e155ddc691591d95335b5d1b25aa9234984a Mon Sep 17 00:00:00 2001 From: Hadas Zeira <82802761+hadasze@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:51:46 +0200 Subject: [PATCH] fixing reduce motion (#1299) --- .../src/components/item/videos/videoItemWrapper.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/gallery/src/components/item/videos/videoItemWrapper.js b/packages/gallery/src/components/item/videos/videoItemWrapper.js index 6b35973a5..728813e4c 100644 --- a/packages/gallery/src/components/item/videos/videoItemWrapper.js +++ b/packages/gallery/src/components/item/videos/videoItemWrapper.js @@ -41,9 +41,16 @@ class VideoItemWrapper extends React.Component { mightPlayVideo() { const { videoPlay, itemClick } = this.props.options; const { hasLink } = this.props; + const prefersReducedMotion = + window.matchMedia && + window.matchMedia('(prefers-reduced-motion: reduce)').matches; + if (this.props.isVideoPlaceholder) { return false; } + if (prefersReducedMotion && videoPlay === 'auto') { + return false; + } if (videoPlay === 'hover' || videoPlay === 'auto') { return true; } else if (itemClick === 'nothing') { @@ -51,7 +58,6 @@ class VideoItemWrapper extends React.Component { } else if (itemClick === 'link' && !hasLink) { return true; } - // } return false; }