@wix/editor-react-components 1.2714.0 → 1.2716.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3357,6 +3357,57 @@ function useTransparentVideo(props) {
3357
3357
  controllerRef.current = null;
3358
3358
  };
3359
3359
  }, [canPlayTransparentVideo]);
3360
+ useEffect(() => {
3361
+ const videoElement = videoRef.current;
3362
+ const player = playerRef.current;
3363
+ if (!canPlayTransparentVideo || videoStartType !== VideoStartType.auto || !videoElement || !player) {
3364
+ return;
3365
+ }
3366
+ let started = false;
3367
+ let isIntersecting = false;
3368
+ let pausedByViewport = false;
3369
+ let pausingByViewport = false;
3370
+ const onPlay = () => {
3371
+ if (!started && !isIntersecting) {
3372
+ pausedByViewport = true;
3373
+ pausingByViewport = true;
3374
+ videoElement.pause();
3375
+ return;
3376
+ }
3377
+ pausedByViewport = false;
3378
+ };
3379
+ const onPause = () => {
3380
+ if (pausingByViewport) {
3381
+ pausingByViewport = false;
3382
+ return;
3383
+ }
3384
+ pausedByViewport = false;
3385
+ };
3386
+ const observer = new IntersectionObserver((entries) => {
3387
+ var _a;
3388
+ isIntersecting = entries[entries.length - 1].isIntersecting;
3389
+ if (isIntersecting) {
3390
+ if (!started || pausedByViewport) {
3391
+ started = true;
3392
+ pausedByViewport = false;
3393
+ (_a = videoElement.play()) == null ? void 0 : _a.catch(() => {
3394
+ });
3395
+ }
3396
+ } else if (!videoElement.paused) {
3397
+ pausedByViewport = true;
3398
+ pausingByViewport = true;
3399
+ videoElement.pause();
3400
+ }
3401
+ });
3402
+ videoElement.addEventListener("play", onPlay);
3403
+ videoElement.addEventListener("pause", onPause);
3404
+ observer.observe(player);
3405
+ return () => {
3406
+ observer.disconnect();
3407
+ videoElement.removeEventListener("play", onPlay);
3408
+ videoElement.removeEventListener("pause", onPause);
3409
+ };
3410
+ }, [canPlayTransparentVideo, videoStartType]);
3360
3411
  const isPlaying = playingState === VideoPlayingState.playing;
3361
3412
  const shouldAutoplay = videoStartType === VideoStartType.auto;
3362
3413
  const shouldReplay = videoEndType !== VideoEndType.stop;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/editor-react-components",
3
- "version": "1.2714.0",
3
+ "version": "1.2716.0",
4
4
  "description": "React components for the Wix Editor",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -85,7 +85,7 @@
85
85
  "@wix/site-service-configuration": "^1.0.1",
86
86
  "@wix/site-service-experiments": "^1.0.4",
87
87
  "@wix/site-service-rendering-context": "^1.0.1",
88
- "@wix/site-ui": "1.280.0",
88
+ "@wix/site-ui": "1.281.0",
89
89
  "@wix/video": "^1.106.0",
90
90
  "@wix/viewer-service-consent-policy": "^1.0.103",
91
91
  "@wix/web-bi-logger": "^2.1.29",
@@ -200,5 +200,5 @@
200
200
  "registry": "https://registry.npmjs.org/",
201
201
  "access": "public"
202
202
  },
203
- "falconPackageHash": "0243bf04c3595a0cbdddbb57fab204dfc607f4522d3d8cfba1b31522"
203
+ "falconPackageHash": "99cd60a0bcf982fa5b28540481a33bf0f3feadbb0104a206e8c4bd05"
204
204
  }