@cntrl-site/components 1.0.103 → 1.0.105
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.
- package/dist/Components/helpers/LazyVideo/LazyVideo.d.ts +4 -0
- package/dist/Components/utils/index.d.ts +1 -0
- package/dist/Components/utils/observeIntersection.d.ts +4 -0
- package/dist/Components/utils/useLazyVideos.d.ts +12 -0
- package/dist/Grid-BBpdl60K.js +374 -0
- package/dist/Grid-DS53S_gA.mjs +1576 -0
- package/dist/{Helix-BmkAKT1G.mjs → Helix-BPn9V1sg.mjs} +53 -53
- package/dist/{Helix-2Vr-9WBa.js → Helix-DcgsCc4D.js} +2 -2
- package/dist/{Hive-BGMWinrW.mjs → Hive-D6-R6TwM.mjs} +114 -111
- package/dist/Hive-n8Fz-j3o.js +321 -0
- package/dist/LazyVideo-CdAWymKO.mjs +15 -0
- package/dist/LazyVideo-imbU18js.js +1 -0
- package/dist/Marquee-DOIRRCu4.js +133 -0
- package/dist/Marquee-O_PDwlIb.mjs +564 -0
- package/dist/MarqueeText-DkaO2lQ5.js +132 -0
- package/dist/MarqueeText-Rzt2fJYt.mjs +517 -0
- package/dist/{Mercury-DuKJQ1Zo.mjs → Mercury-C9D10TTT.mjs} +55 -54
- package/dist/Mercury-DynO-NxY.js +267 -0
- package/dist/{PretextComponent-CGycuNNn.js → PretextComponent-BnsS2zJ6.js} +1 -1
- package/dist/{PretextComponent-DN8cyZ8x.mjs → PretextComponent-j-OsRZTx.mjs} +7 -7
- package/dist/Waterfall-DC2WQ3GT.js +287 -0
- package/dist/{Waterfall-A0FjM2my.mjs → Waterfall-Yud2VR62.mjs} +299 -295
- package/dist/{components-DTCDEBo0.js → components-B9Vdjf0w.js} +1 -1
- package/dist/{components-BFJINCME.mjs → components-D2LyuDm-.mjs} +1 -1
- package/dist/elements.js +1 -1
- package/dist/elements.mjs +7 -7
- package/dist/elements.node.js +1 -1
- package/dist/elements.node.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +2 -2
- package/dist/observeIntersection-B0f3L2iK.mjs +23 -0
- package/dist/observeIntersection-DxGj9Ctt.js +1 -0
- package/dist/sources.js +147 -59
- package/dist/sources.mjs +155 -67
- package/dist/useLazyVideos-CdCbc2j0.js +1 -0
- package/dist/useLazyVideos-CxXyEjRQ.mjs +52 -0
- package/dist/utils.js +1 -1
- package/dist/utils.mjs +14 -12
- package/package.json +5 -3
- package/dist/Grid-CemGhf3F.js +0 -374
- package/dist/Grid-cfQsXW3b.mjs +0 -1553
- package/dist/Hive-BC6zQBsv.js +0 -321
- package/dist/Marquee-BYClHHws.mjs +0 -551
- package/dist/Marquee-vmHaTGIP.js +0 -133
- package/dist/MarqueeText-4Rip_sQX.mjs +0 -515
- package/dist/MarqueeText-E6OubMOG.js +0 -132
- package/dist/Mercury-BwF_XW2w.js +0 -267
- package/dist/Waterfall-DnPDHbCL.js +0 -287
package/dist/sources.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./PretextComponent-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./PretextComponent-BnsS2zJ6.js"),e=`import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent, type PointerEvent, type ReactNode } from 'react';
|
|
2
2
|
import { CommonComponentProps } from '../props';
|
|
3
3
|
import { buildColorVars, scalingValue, useScopedStyles } from '../utils';
|
|
4
4
|
import { useLightboxScrollLock } from '../utils/useLightboxScrollLock';
|
|
@@ -4565,12 +4565,14 @@ import {
|
|
|
4565
4565
|
buildColorVars,
|
|
4566
4566
|
getFormFieldValidationError,
|
|
4567
4567
|
scalingValue,
|
|
4568
|
+
useLazyVideos,
|
|
4568
4569
|
useScopedStyles,
|
|
4569
4570
|
} from '../utils/index';
|
|
4570
4571
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState, useMemo } from 'react';
|
|
4571
4572
|
import { createPortal } from 'react-dom';
|
|
4572
4573
|
import { omitTextColors, TextStyles, textStylesToCss } from '../utils/textStylesToCss';
|
|
4573
4574
|
import { SvgImage } from '../helpers/SvgImage/SvgImage';
|
|
4575
|
+
import { LazyVideo } from '../helpers/LazyVideo/LazyVideo';
|
|
4574
4576
|
|
|
4575
4577
|
function sv(px: number): string {
|
|
4576
4578
|
return \`calc(var(--cntrl-article-width, 100vw) * \${px / 1440})\`;
|
|
@@ -5140,10 +5142,13 @@ function collectGridLightboxMedia(content: any[]): GridMedia[] {
|
|
|
5140
5142
|
}
|
|
5141
5143
|
|
|
5142
5144
|
function LightboxMediaPreloadPool({ mediaList }: { mediaList: GridMedia[] }) {
|
|
5145
|
+
const [pool, setPool] = useState<HTMLDivElement | null>(null);
|
|
5146
|
+
useLazyVideos(pool, { preload: 'metadata' });
|
|
5143
5147
|
if (mediaList.length === 0) return null;
|
|
5144
5148
|
|
|
5145
5149
|
return (
|
|
5146
5150
|
<div
|
|
5151
|
+
ref={setPool}
|
|
5147
5152
|
aria-hidden
|
|
5148
5153
|
style={{
|
|
5149
5154
|
position: 'absolute',
|
|
@@ -5159,7 +5164,7 @@ function LightboxMediaPreloadPool({ mediaList }: { mediaList: GridMedia[] }) {
|
|
|
5159
5164
|
<video
|
|
5160
5165
|
key={media.assetId}
|
|
5161
5166
|
src={media.assetId}
|
|
5162
|
-
preload='
|
|
5167
|
+
preload='none'
|
|
5163
5168
|
muted
|
|
5164
5169
|
playsInline
|
|
5165
5170
|
/>
|
|
@@ -5181,33 +5186,46 @@ function unloadVideoElement(video: HTMLVideoElement) {
|
|
|
5181
5186
|
video.load();
|
|
5182
5187
|
}
|
|
5183
5188
|
|
|
5189
|
+
const SPLIDE_SLIDE_VIDEOS = '.splide__slide video';
|
|
5190
|
+
|
|
5191
|
+
function shouldPlaySlideVideo(video: HTMLVideoElement): boolean {
|
|
5192
|
+
if (video.closest('.splide--fade, .splide__slide.is-active:not(.splide__slide--clone), .splide__slide.is-next')) return true;
|
|
5193
|
+
const slide = video.closest<HTMLElement>('.splide__slide');
|
|
5194
|
+
if (!slide || slide.classList.contains('splide__slide--clone')) return false;
|
|
5195
|
+
const slideIndex = slide.dataset.slideIndex;
|
|
5196
|
+
const upcomingSlide = slide.parentElement?.querySelector<HTMLElement>('.splide__slide.is-next');
|
|
5197
|
+
return slideIndex !== undefined && upcomingSlide?.dataset.slideIndex === slideIndex;
|
|
5198
|
+
}
|
|
5199
|
+
|
|
5184
5200
|
function GridMediaItem({
|
|
5185
5201
|
media,
|
|
5186
5202
|
className,
|
|
5187
5203
|
style,
|
|
5204
|
+
isSplideSlide = false,
|
|
5188
5205
|
onMediaClick,
|
|
5189
5206
|
}: {
|
|
5190
5207
|
media: GridMedia;
|
|
5191
5208
|
className: string;
|
|
5192
5209
|
style: React.CSSProperties;
|
|
5210
|
+
isSplideSlide?: boolean;
|
|
5193
5211
|
onMediaClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
5194
5212
|
}) {
|
|
5195
5213
|
if (isVideoMedia(media)) {
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
style
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
/>
|
|
5210
|
-
|
|
5214
|
+
const videoProps = {
|
|
5215
|
+
src: media.assetId,
|
|
5216
|
+
className,
|
|
5217
|
+
style: {
|
|
5218
|
+
...style,
|
|
5219
|
+
cursor: onMediaClick ? 'pointer' : 'default',
|
|
5220
|
+
},
|
|
5221
|
+
muted: true,
|
|
5222
|
+
loop: true,
|
|
5223
|
+
playsInline: true,
|
|
5224
|
+
onClick: onMediaClick,
|
|
5225
|
+
};
|
|
5226
|
+
return isSplideSlide
|
|
5227
|
+
? <video {...videoProps} preload='none' />
|
|
5228
|
+
: <LazyVideo {...videoProps} autoPlay />;
|
|
5211
5229
|
}
|
|
5212
5230
|
|
|
5213
5231
|
return (
|
|
@@ -5224,6 +5242,25 @@ function GridMediaItem({
|
|
|
5224
5242
|
);
|
|
5225
5243
|
}
|
|
5226
5244
|
|
|
5245
|
+
function GridItemMediaWrapper({
|
|
5246
|
+
className,
|
|
5247
|
+
style,
|
|
5248
|
+
children,
|
|
5249
|
+
}: {
|
|
5250
|
+
className: string;
|
|
5251
|
+
style: React.CSSProperties;
|
|
5252
|
+
children: React.ReactNode;
|
|
5253
|
+
}) {
|
|
5254
|
+
const [wrapper, setWrapper] = useState<HTMLDivElement | null>(null);
|
|
5255
|
+
useLazyVideos(wrapper, { autoPlay: true, selector: SPLIDE_SLIDE_VIDEOS, shouldPlay: shouldPlaySlideVideo });
|
|
5256
|
+
|
|
5257
|
+
return (
|
|
5258
|
+
<div ref={setWrapper} className={className} style={style}>
|
|
5259
|
+
{children}
|
|
5260
|
+
</div>
|
|
5261
|
+
);
|
|
5262
|
+
}
|
|
5263
|
+
|
|
5227
5264
|
function getGhostRect(ghost: HTMLElement): AnimRect {
|
|
5228
5265
|
const cb = ghost.getBoundingClientRect();
|
|
5229
5266
|
return { width: cb.width, height: cb.height, left: cb.left, top: cb.top };
|
|
@@ -6545,7 +6582,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
6545
6582
|
.map(entry => entry.lightboxMedia!);
|
|
6546
6583
|
|
|
6547
6584
|
const imageContent = (
|
|
6548
|
-
<
|
|
6585
|
+
<GridItemMediaWrapper className={imageWrapperClassName} style={imageWrapperStyle}>
|
|
6549
6586
|
{displayItems.length === 0
|
|
6550
6587
|
? null
|
|
6551
6588
|
: slider === 'off'
|
|
@@ -6572,7 +6609,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
6572
6609
|
<div className={\`\${P}-item-image-wrapper-sizer\`} aria-hidden="true">
|
|
6573
6610
|
{displayItems.map(({ displayMedia }) => (
|
|
6574
6611
|
isVideoMedia(displayMedia) ? (
|
|
6575
|
-
<
|
|
6612
|
+
<LazyVideo key={\`sizer-\${displayMedia.assetId}\`} src={displayMedia.assetId} nearPreload='metadata' muted playsInline />
|
|
6576
6613
|
) : (
|
|
6577
6614
|
<img key={\`sizer-\${displayMedia.assetId}\`} src={displayMedia.assetId} alt="" />
|
|
6578
6615
|
)
|
|
@@ -6608,11 +6645,12 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
6608
6645
|
? lightboxItemsForEntry.findIndex(item => item.assetId === lightboxMedia.assetId)
|
|
6609
6646
|
: -1;
|
|
6610
6647
|
return (
|
|
6611
|
-
<SplideSlide key={imgIndex}>
|
|
6648
|
+
<SplideSlide key={imgIndex} data-slide-index={imgIndex}>
|
|
6612
6649
|
<GridMediaItem
|
|
6613
6650
|
media={displayMedia}
|
|
6614
6651
|
className={\`\${P}-item-\${isVideoMedia(displayMedia) ? 'video' : 'image'}\`.trim()}
|
|
6615
6652
|
style={imageStyle}
|
|
6653
|
+
isSplideSlide
|
|
6616
6654
|
onMediaClick={canOpenLightboxMedia && lightboxIndex >= 0
|
|
6617
6655
|
? () => openLightbox(lightboxItemsForEntry, lightboxIndex)
|
|
6618
6656
|
: undefined}
|
|
@@ -6623,7 +6661,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
6623
6661
|
</Splide>
|
|
6624
6662
|
</>
|
|
6625
6663
|
}
|
|
6626
|
-
</
|
|
6664
|
+
</GridItemMediaWrapper>
|
|
6627
6665
|
);
|
|
6628
6666
|
|
|
6629
6667
|
const typeABText = !isTextBeforeImage ? (
|
|
@@ -6830,6 +6868,7 @@ const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
|
|
|
6830
6868
|
import { CommonComponentProps } from '../props';
|
|
6831
6869
|
import { scalingValue } from '../utils/scalingValue';
|
|
6832
6870
|
import { useScopedStyles } from '../utils/useScopedStyles';
|
|
6871
|
+
import { LazyVideo } from '../helpers/LazyVideo/LazyVideo';
|
|
6833
6872
|
|
|
6834
6873
|
const DEG_PER_SEC_PER_SPEED_UNIT = 10;
|
|
6835
6874
|
const MAX_TOTAL_ITEMS = 400;
|
|
@@ -7342,7 +7381,7 @@ export function Helix({
|
|
|
7342
7381
|
}
|
|
7343
7382
|
: mediaStyle;
|
|
7344
7383
|
const mediaNode = isVideoMedia(media) ? (
|
|
7345
|
-
<
|
|
7384
|
+
<LazyVideo
|
|
7346
7385
|
className={\`\${P}-media\`}
|
|
7347
7386
|
style={coverMediaStyle}
|
|
7348
7387
|
src={media.assetId}
|
|
@@ -7350,7 +7389,6 @@ export function Helix({
|
|
|
7350
7389
|
loop
|
|
7351
7390
|
autoPlay
|
|
7352
7391
|
playsInline
|
|
7353
|
-
preload="auto"
|
|
7354
7392
|
/>
|
|
7355
7393
|
) : (
|
|
7356
7394
|
<img
|
|
@@ -7387,7 +7425,8 @@ export function Helix({
|
|
|
7387
7425
|
);
|
|
7388
7426
|
}
|
|
7389
7427
|
`,s=`import { CommonComponentProps } from '../props';
|
|
7390
|
-
import { scalingValue, useScopedStyles } from '../utils/index';
|
|
7428
|
+
import { scalingValue, useLazyVideos, useScopedStyles } from '../utils/index';
|
|
7429
|
+
import { LazyVideo } from '../helpers/LazyVideo/LazyVideo';
|
|
7391
7430
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
7392
7431
|
import { createPortal } from 'react-dom';
|
|
7393
7432
|
import {
|
|
@@ -7991,10 +8030,13 @@ function collectAllHiveMedia(content: HiveContentItem[]): HiveMedia[] {
|
|
|
7991
8030
|
}
|
|
7992
8031
|
|
|
7993
8032
|
function PreloadedMediaPool({ mediaList }: { mediaList: HiveMedia[] }) {
|
|
8033
|
+
const [pool, setPool] = useState<HTMLDivElement | null>(null);
|
|
8034
|
+
useLazyVideos(pool, { preload: 'metadata' });
|
|
7994
8035
|
if (mediaList.length === 0) return null;
|
|
7995
8036
|
|
|
7996
8037
|
return (
|
|
7997
8038
|
<div
|
|
8039
|
+
ref={setPool}
|
|
7998
8040
|
aria-hidden
|
|
7999
8041
|
style={{
|
|
8000
8042
|
position: 'absolute',
|
|
@@ -8010,7 +8052,7 @@ function PreloadedMediaPool({ mediaList }: { mediaList: HiveMedia[] }) {
|
|
|
8010
8052
|
<video
|
|
8011
8053
|
key={media.assetId}
|
|
8012
8054
|
src={media.assetId}
|
|
8013
|
-
preload='
|
|
8055
|
+
preload='none'
|
|
8014
8056
|
muted
|
|
8015
8057
|
playsInline
|
|
8016
8058
|
/>
|
|
@@ -8229,7 +8271,7 @@ function MediaItem({
|
|
|
8229
8271
|
}) {
|
|
8230
8272
|
if (isVideoMedia(media)) {
|
|
8231
8273
|
return (
|
|
8232
|
-
<
|
|
8274
|
+
<LazyVideo
|
|
8233
8275
|
src={media.assetId}
|
|
8234
8276
|
className={className}
|
|
8235
8277
|
data-hive-grid-index={gridIndex}
|
|
@@ -8241,7 +8283,6 @@ function MediaItem({
|
|
|
8241
8283
|
autoPlay
|
|
8242
8284
|
loop
|
|
8243
8285
|
playsInline
|
|
8244
|
-
preload='auto'
|
|
8245
8286
|
onClick={onMediaClick}
|
|
8246
8287
|
/>
|
|
8247
8288
|
);
|
|
@@ -14131,6 +14172,8 @@ import cn from 'classnames';
|
|
|
14131
14172
|
import { CommonComponentProps } from '../props';
|
|
14132
14173
|
import { scalingValue } from '../utils/scalingValue';
|
|
14133
14174
|
import { useScopedStyles } from '../utils/useScopedStyles';
|
|
14175
|
+
import { NEAR_VIEWPORT_MARGIN, observeIntersection } from '../utils/observeIntersection';
|
|
14176
|
+
import { pauseVideo, playVideo, raisePreload } from '../utils/useLazyVideos';
|
|
14134
14177
|
|
|
14135
14178
|
function getCSS(P: string, setWidthPx: number): string {
|
|
14136
14179
|
const distance = setWidthPx > 0 ? \`\${setWidthPx}px\` : '0px';
|
|
@@ -14275,6 +14318,8 @@ const MIN_CONTENT_SEQUENCE_REPEAT = 3;
|
|
|
14275
14318
|
const MAX_CONTENT_SEQUENCE_REPEAT = 12;
|
|
14276
14319
|
const MIN_TRUSTWORTHY_CYCLE_WIDTH_PX = 32;
|
|
14277
14320
|
const OUTER_SET_COPIES = 3;
|
|
14321
|
+
const VIDEO_POLL_MS = 250;
|
|
14322
|
+
const VIDEO_LOOKAHEAD_WRAPPER_WIDTHS = 0.5;
|
|
14278
14323
|
|
|
14279
14324
|
const restartTrackAnimation = (track: HTMLElement) => {
|
|
14280
14325
|
track.style.setProperty('animation-name', 'none');
|
|
@@ -14364,7 +14409,7 @@ const isVideoMedia = (media: Pick<NonNullable<MarqueeItem['image']>, 'assetId' |
|
|
|
14364
14409
|
|
|
14365
14410
|
const isMediaReady = (el: HTMLImageElement | HTMLVideoElement | null): boolean => {
|
|
14366
14411
|
if (!el) return false;
|
|
14367
|
-
if (el instanceof HTMLVideoElement) return el.readyState >=
|
|
14412
|
+
if (el instanceof HTMLVideoElement) return el.readyState >= 1;
|
|
14368
14413
|
return el.complete;
|
|
14369
14414
|
};
|
|
14370
14415
|
|
|
@@ -14448,10 +14493,9 @@ const MarqueeItemCard = ({
|
|
|
14448
14493
|
style={mediaStyle}
|
|
14449
14494
|
muted
|
|
14450
14495
|
loop
|
|
14451
|
-
autoPlay
|
|
14452
14496
|
playsInline
|
|
14453
|
-
preload="
|
|
14454
|
-
|
|
14497
|
+
preload="none"
|
|
14498
|
+
onLoadedMetadata={isFirstSet ? onFirstSetImageDone : undefined}
|
|
14455
14499
|
onError={isFirstSet ? onFirstSetImageDone : undefined}
|
|
14456
14500
|
/>
|
|
14457
14501
|
) : (
|
|
@@ -14526,6 +14570,7 @@ export const Marquee = ({ settings, content, isEditor, isPreviewMode, isEditMode
|
|
|
14526
14570
|
cornerRadius = 0,
|
|
14527
14571
|
} = settings;
|
|
14528
14572
|
const imageFit = useMemo(() => normalizeImageFit(settings.imageFit), [settings.imageFit]);
|
|
14573
|
+
const needsVideoMetadata = imageFit.display !== 'cover';
|
|
14529
14574
|
const originalItemCount = content?.length ?? 0;
|
|
14530
14575
|
const showControls = Boolean(isEditMode);
|
|
14531
14576
|
const showHoverEffects = !isEditor || Boolean(isPreviewMode);
|
|
@@ -14623,26 +14668,56 @@ export const Marquee = ({ settings, content, isEditor, isPreviewMode, isEditMode
|
|
|
14623
14668
|
};
|
|
14624
14669
|
}, [hoverEffect, swappedSlots, showHoverEffects]);
|
|
14625
14670
|
|
|
14626
|
-
// Only decode videos that are actually visible: the track renders many copies of each item,
|
|
14627
|
-
// and playing all of them at once saturates the decoder and drops frames.
|
|
14628
14671
|
useEffect(() => {
|
|
14629
14672
|
const wrapper = wrapperRef.current;
|
|
14630
14673
|
if (!wrapper || typeof IntersectionObserver === 'undefined') return;
|
|
14631
|
-
|
|
14632
|
-
|
|
14633
|
-
|
|
14634
|
-
|
|
14635
|
-
|
|
14636
|
-
|
|
14637
|
-
|
|
14638
|
-
|
|
14639
|
-
|
|
14674
|
+
let isNear = false;
|
|
14675
|
+
let isVisible = false;
|
|
14676
|
+
let pollTimer: ReturnType<typeof setInterval> | undefined;
|
|
14677
|
+
const syncVideos = () => {
|
|
14678
|
+
const videos = wrapper.querySelectorAll('video');
|
|
14679
|
+
if (!isNear) {
|
|
14680
|
+
videos.forEach(pauseVideo);
|
|
14681
|
+
return;
|
|
14682
|
+
}
|
|
14683
|
+
const wrapperRect = wrapper.getBoundingClientRect();
|
|
14684
|
+
const lookahead = wrapperRect.width * VIDEO_LOOKAHEAD_WRAPPER_WIDTHS;
|
|
14685
|
+
videos.forEach((video) => {
|
|
14686
|
+
const rect = video.getBoundingClientRect();
|
|
14687
|
+
const isInView = rect.right > wrapperRect.left && rect.left < wrapperRect.right;
|
|
14688
|
+
const isNearView = rect.right > wrapperRect.left - lookahead && rect.left < wrapperRect.right + lookahead;
|
|
14689
|
+
if (isNearView) raisePreload(video, 'auto');
|
|
14690
|
+
else if (needsVideoMetadata) raisePreload(video, 'metadata');
|
|
14691
|
+
if (isVisible && isInView) {
|
|
14692
|
+
if (video.paused) playVideo(video);
|
|
14693
|
+
} else {
|
|
14694
|
+
pauseVideo(video);
|
|
14640
14695
|
}
|
|
14696
|
+
});
|
|
14697
|
+
};
|
|
14698
|
+
const update = () => {
|
|
14699
|
+
if (isNear && pollTimer === undefined) {
|
|
14700
|
+
pollTimer = setInterval(syncVideos, VIDEO_POLL_MS);
|
|
14701
|
+
} else if (!isNear && pollTimer !== undefined) {
|
|
14702
|
+
clearInterval(pollTimer);
|
|
14703
|
+
pollTimer = undefined;
|
|
14641
14704
|
}
|
|
14642
|
-
|
|
14643
|
-
|
|
14644
|
-
|
|
14645
|
-
|
|
14705
|
+
syncVideos();
|
|
14706
|
+
};
|
|
14707
|
+
const stopNear = observeIntersection(wrapper, NEAR_VIEWPORT_MARGIN, (intersecting) => {
|
|
14708
|
+
isNear = intersecting;
|
|
14709
|
+
update();
|
|
14710
|
+
});
|
|
14711
|
+
const stopVisible = observeIntersection(wrapper, '0px', (intersecting) => {
|
|
14712
|
+
isVisible = intersecting;
|
|
14713
|
+
update();
|
|
14714
|
+
});
|
|
14715
|
+
return () => {
|
|
14716
|
+
stopNear();
|
|
14717
|
+
stopVisible();
|
|
14718
|
+
clearInterval(pollTimer);
|
|
14719
|
+
};
|
|
14720
|
+
}, [useMarqueeTrack, needsVideoMetadata]);
|
|
14646
14721
|
|
|
14647
14722
|
useLayoutEffect(() => {
|
|
14648
14723
|
if (!useMarqueeTrack) return;
|
|
@@ -14936,6 +15011,7 @@ import { CommonComponentProps } from '../props';
|
|
|
14936
15011
|
import { scalingValue } from '../utils/scalingValue';
|
|
14937
15012
|
import { useScopedStyles } from '../utils/useScopedStyles';
|
|
14938
15013
|
import { textStylesToCss } from '../utils/textStylesToCss';
|
|
15014
|
+
import { observeIntersection } from '../utils/observeIntersection';
|
|
14939
15015
|
|
|
14940
15016
|
function getCSS(P: string, setWidthPx: number, isCurve: boolean): string {
|
|
14941
15017
|
const distance = setWidthPx > 0 ? \`\${setWidthPx}px\` : '0px';
|
|
@@ -15535,9 +15611,11 @@ export const MarqueeText = ({ settings, content, isEditor, isPreviewMode }: Marq
|
|
|
15535
15611
|
const wrapper = wrapperRef.current;
|
|
15536
15612
|
if (!wrapper) return;
|
|
15537
15613
|
|
|
15614
|
+
const canObserve = typeof IntersectionObserver !== 'undefined';
|
|
15538
15615
|
const wave = {
|
|
15539
15616
|
raf: 0,
|
|
15540
15617
|
cancelled: false,
|
|
15618
|
+
isOnScreen: !canObserve,
|
|
15541
15619
|
lut: null as WaveArcLut | null,
|
|
15542
15620
|
lutKey: '',
|
|
15543
15621
|
itemsCache: [] as WaveItemCache[],
|
|
@@ -15624,18 +15702,24 @@ export const MarqueeText = ({ settings, content, isEditor, isPreviewMode }: Marq
|
|
|
15624
15702
|
if (wave.cancelled) return;
|
|
15625
15703
|
wave.raf = 0;
|
|
15626
15704
|
applyWave();
|
|
15627
|
-
if (waveShouldLoopRef.current && !document.hidden) {
|
|
15705
|
+
if (waveShouldLoopRef.current && wave.isOnScreen && !document.hidden) {
|
|
15628
15706
|
wave.raf = requestAnimationFrame(tick);
|
|
15629
15707
|
}
|
|
15630
15708
|
};
|
|
15631
15709
|
|
|
15632
15710
|
const kick = () => {
|
|
15633
|
-
if (wave.cancelled || wave.raf) return;
|
|
15711
|
+
if (wave.cancelled || wave.raf || !wave.isOnScreen) return;
|
|
15634
15712
|
wave.raf = requestAnimationFrame(tick);
|
|
15635
15713
|
};
|
|
15636
15714
|
|
|
15715
|
+
const stop = () => {
|
|
15716
|
+
cancelAnimationFrame(wave.raf);
|
|
15717
|
+
wave.raf = 0;
|
|
15718
|
+
};
|
|
15719
|
+
|
|
15637
15720
|
const invalidate = () => {
|
|
15638
15721
|
wave.cacheDirty = true;
|
|
15722
|
+
if (!wave.isOnScreen) return;
|
|
15639
15723
|
applyWave();
|
|
15640
15724
|
kick();
|
|
15641
15725
|
};
|
|
@@ -15644,15 +15728,16 @@ export const MarqueeText = ({ settings, content, isEditor, isPreviewMode }: Marq
|
|
|
15644
15728
|
waveInvalidateRef.current = invalidate;
|
|
15645
15729
|
applyWave();
|
|
15646
15730
|
kick();
|
|
15731
|
+
const stopObserving = canObserve
|
|
15732
|
+
? observeIntersection(wrapper, '0px', (isIntersecting) => {
|
|
15733
|
+
wave.isOnScreen = isIntersecting;
|
|
15734
|
+
if (isIntersecting) invalidate();
|
|
15735
|
+
else stop();
|
|
15736
|
+
})
|
|
15737
|
+
: null;
|
|
15647
15738
|
const onVisibility = () => {
|
|
15648
|
-
|
|
15649
|
-
|
|
15650
|
-
wave.raf = 0;
|
|
15651
|
-
return;
|
|
15652
|
-
}
|
|
15653
|
-
cancelAnimationFrame(wave.raf);
|
|
15654
|
-
wave.raf = 0;
|
|
15655
|
-
invalidate();
|
|
15739
|
+
stop();
|
|
15740
|
+
if (!document.hidden) invalidate();
|
|
15656
15741
|
};
|
|
15657
15742
|
document.addEventListener('visibilitychange', onVisibility);
|
|
15658
15743
|
window.addEventListener('pageshow', onVisibility);
|
|
@@ -15662,6 +15747,7 @@ export const MarqueeText = ({ settings, content, isEditor, isPreviewMode }: Marq
|
|
|
15662
15747
|
wave.cancelled = true;
|
|
15663
15748
|
waveKickRef.current = null;
|
|
15664
15749
|
waveInvalidateRef.current = null;
|
|
15750
|
+
stopObserving?.();
|
|
15665
15751
|
cancelAnimationFrame(wave.raf);
|
|
15666
15752
|
document.removeEventListener('visibilitychange', onVisibility);
|
|
15667
15753
|
window.removeEventListener('pageshow', onVisibility);
|
|
@@ -15876,6 +15962,7 @@ import {
|
|
|
15876
15962
|
} from '../utils/index';
|
|
15877
15963
|
import { omitTextColors, TextStyles, textStylesToCss } from '../utils/textStylesToCss';
|
|
15878
15964
|
import { SvgImage } from '../helpers/SvgImage/SvgImage';
|
|
15965
|
+
import { LazyVideo } from '../helpers/LazyVideo/LazyVideo';
|
|
15879
15966
|
|
|
15880
15967
|
const DEFAULT_IMG_WIDTH = 300 / 1440;
|
|
15881
15968
|
const DEFAULT_CORNER_RADIUS = 8 / 1440;
|
|
@@ -17321,7 +17408,7 @@ function GalleryMediaItem({
|
|
|
17321
17408
|
const galleryPaddingBetweenHeight = Math.max(galleryPaddingBetween, PADDING_HANDLE_SIZE);
|
|
17322
17409
|
|
|
17323
17410
|
const mediaNode = isVideoMedia(media) ? (
|
|
17324
|
-
<
|
|
17411
|
+
<LazyVideo
|
|
17325
17412
|
{...mediaProps}
|
|
17326
17413
|
src={media.assetId}
|
|
17327
17414
|
muted
|
|
@@ -23354,6 +23441,7 @@ import { createPortal } from 'react-dom';
|
|
|
23354
23441
|
import { CommonComponentProps } from '../props';
|
|
23355
23442
|
import { getContainedMediaTransformOrigin } from '../utils/getImageRect';
|
|
23356
23443
|
import { scalingValue, useScopedStyles } from '../utils/index';
|
|
23444
|
+
import { LazyVideo } from '../helpers/LazyVideo/LazyVideo';
|
|
23357
23445
|
import { textStylesToCss, type TextStyles } from '../utils/textStylesToCss';
|
|
23358
23446
|
import {
|
|
23359
23447
|
Lightbox,
|
|
@@ -23782,7 +23870,7 @@ export function Waterfall({
|
|
|
23782
23870
|
].filter(Boolean).join(' ')}
|
|
23783
23871
|
>
|
|
23784
23872
|
{item.image.type === 'video' ? (
|
|
23785
|
-
<
|
|
23873
|
+
<LazyVideo
|
|
23786
23874
|
ref={syncFitMediaLayout}
|
|
23787
23875
|
src={item.image.assetId}
|
|
23788
23876
|
data-waterfall-index={index}
|
|
@@ -23792,7 +23880,7 @@ export function Waterfall({
|
|
|
23792
23880
|
loop
|
|
23793
23881
|
autoPlay
|
|
23794
23882
|
onClick={handleOpen}
|
|
23795
|
-
|
|
23883
|
+
onLoadedMetadata={(e) => syncFitMediaLayout(e.currentTarget)}
|
|
23796
23884
|
/>
|
|
23797
23885
|
) : (
|
|
23798
23886
|
<img
|