Sticker View: Fix playing animation when not in viewport
This commit is contained in:
parent
47a6cf312c
commit
fe95ac554f
@ -34,7 +34,7 @@ type OwnProps = {
|
|||||||
withGridFix?: boolean;
|
withGridFix?: boolean;
|
||||||
shouldPreloadPreview?: boolean;
|
shouldPreloadPreview?: boolean;
|
||||||
forceOnHeavyAnimation?: boolean;
|
forceOnHeavyAnimation?: boolean;
|
||||||
observeIntersection?: ObserveFn;
|
observeIntersectionForLoading?: ObserveFn;
|
||||||
observeIntersectionForPlaying?: ObserveFn;
|
observeIntersectionForPlaying?: ObserveFn;
|
||||||
onClick?: NoneToVoidFunction;
|
onClick?: NoneToVoidFunction;
|
||||||
};
|
};
|
||||||
@ -52,7 +52,7 @@ const CustomEmoji: FC<OwnProps> = ({
|
|||||||
shouldPreloadPreview,
|
shouldPreloadPreview,
|
||||||
forceOnHeavyAnimation,
|
forceOnHeavyAnimation,
|
||||||
withSharedAnimation,
|
withSharedAnimation,
|
||||||
observeIntersection,
|
observeIntersectionForLoading,
|
||||||
observeIntersectionForPlaying,
|
observeIntersectionForPlaying,
|
||||||
onClick,
|
onClick,
|
||||||
}) => {
|
}) => {
|
||||||
@ -143,8 +143,8 @@ const CustomEmoji: FC<OwnProps> = ({
|
|||||||
shouldLoop={shouldLoop}
|
shouldLoop={shouldLoop}
|
||||||
loopLimit={loopLimit}
|
loopLimit={loopLimit}
|
||||||
shouldPreloadPreview={shouldPreloadPreview}
|
shouldPreloadPreview={shouldPreloadPreview}
|
||||||
observeIntersection={observeIntersection}
|
|
||||||
forceOnHeavyAnimation={forceOnHeavyAnimation}
|
forceOnHeavyAnimation={forceOnHeavyAnimation}
|
||||||
|
observeIntersectionForLoading={observeIntersectionForLoading}
|
||||||
observeIntersectionForPlaying={observeIntersectionForPlaying}
|
observeIntersectionForPlaying={observeIntersectionForPlaying}
|
||||||
withSharedAnimation={withSharedAnimation}
|
withSharedAnimation={withSharedAnimation}
|
||||||
onVideoEnded={handleVideoEnded}
|
onVideoEnded={handleVideoEnded}
|
||||||
|
|||||||
@ -64,7 +64,7 @@ const FullNameTitle: FC<OwnProps> = ({
|
|||||||
<CustomEmoji
|
<CustomEmoji
|
||||||
documentId={emojiStatus.documentId}
|
documentId={emojiStatus.documentId}
|
||||||
loopLimit={!noLoopLimit ? EMOJI_STATUS_LOOP_LIMIT : undefined}
|
loopLimit={!noLoopLimit ? EMOJI_STATUS_LOOP_LIMIT : undefined}
|
||||||
observeIntersection={observeIntersection}
|
observeIntersectionForLoading={observeIntersection}
|
||||||
onClick={onEmojiStatusClick}
|
onClick={onEmojiStatusClick}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -36,7 +36,7 @@ type OwnProps = {
|
|||||||
shouldLoop?: boolean;
|
shouldLoop?: boolean;
|
||||||
shouldPreloadPreview?: boolean;
|
shouldPreloadPreview?: boolean;
|
||||||
forceOnHeavyAnimation?: boolean;
|
forceOnHeavyAnimation?: boolean;
|
||||||
observeIntersection?: ObserveFn;
|
observeIntersectionForLoading?: ObserveFn;
|
||||||
observeIntersectionForPlaying?: ObserveFn;
|
observeIntersectionForPlaying?: ObserveFn;
|
||||||
noLoad?: boolean;
|
noLoad?: boolean;
|
||||||
noPlay?: boolean;
|
noPlay?: boolean;
|
||||||
@ -63,7 +63,7 @@ const StickerView: FC<OwnProps> = ({
|
|||||||
shouldLoop = false,
|
shouldLoop = false,
|
||||||
shouldPreloadPreview,
|
shouldPreloadPreview,
|
||||||
forceOnHeavyAnimation,
|
forceOnHeavyAnimation,
|
||||||
observeIntersection,
|
observeIntersectionForLoading,
|
||||||
observeIntersectionForPlaying,
|
observeIntersectionForPlaying,
|
||||||
noLoad,
|
noLoad,
|
||||||
noPlay,
|
noPlay,
|
||||||
@ -80,9 +80,12 @@ const StickerView: FC<OwnProps> = ({
|
|||||||
const isStatic = !isLottie && !isVideo;
|
const isStatic = !isLottie && !isVideo;
|
||||||
const previewMediaHash = getStickerPreviewHash(sticker.id);
|
const previewMediaHash = getStickerPreviewHash(sticker.id);
|
||||||
|
|
||||||
const isIntersectingForLoad = useIsIntersecting(containerRef, observeIntersection);
|
const isIntersectingForLoading = useIsIntersecting(containerRef, observeIntersectionForLoading);
|
||||||
const shouldLoad = isIntersectingForLoad && !noLoad;
|
const shouldLoad = isIntersectingForLoading && !noLoad;
|
||||||
const isIntersectingForPlaying = useIsIntersecting(containerRef, observeIntersectionForPlaying);
|
const isIntersectingForPlaying = (
|
||||||
|
useIsIntersecting(containerRef, observeIntersectionForPlaying)
|
||||||
|
&& isIntersectingForLoading
|
||||||
|
);
|
||||||
const shouldPlay = isIntersectingForPlaying && !noPlay;
|
const shouldPlay = isIntersectingForPlaying && !noPlay;
|
||||||
|
|
||||||
const thumbDataUri = useThumbnail(sticker);
|
const thumbDataUri = useThumbnail(sticker);
|
||||||
|
|||||||
@ -22,7 +22,8 @@ export function renderMessageText(
|
|||||||
isSimple?: boolean,
|
isSimple?: boolean,
|
||||||
truncateLength?: number,
|
truncateLength?: number,
|
||||||
isProtected?: boolean,
|
isProtected?: boolean,
|
||||||
observeIntersection?: ObserveFn,
|
observeIntersectionForLoading?: ObserveFn,
|
||||||
|
observeIntersectionForPlaying?: ObserveFn,
|
||||||
shouldRenderAsHtml?: boolean,
|
shouldRenderAsHtml?: boolean,
|
||||||
) {
|
) {
|
||||||
const { text, entities } = message.content.text || {};
|
const { text, entities } = message.content.text || {};
|
||||||
@ -41,7 +42,8 @@ export function renderMessageText(
|
|||||||
message.id,
|
message.id,
|
||||||
isSimple,
|
isSimple,
|
||||||
isProtected,
|
isProtected,
|
||||||
observeIntersection,
|
observeIntersectionForLoading,
|
||||||
|
observeIntersectionForPlaying,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,8 @@ export function renderTextWithEntities(
|
|||||||
messageId?: number,
|
messageId?: number,
|
||||||
isSimple?: boolean,
|
isSimple?: boolean,
|
||||||
isProtected?: boolean,
|
isProtected?: boolean,
|
||||||
observeIntersection?: ObserveFn,
|
observeIntersectionForLoading?: ObserveFn,
|
||||||
|
observeIntersectionForPlaying?: ObserveFn,
|
||||||
) {
|
) {
|
||||||
if (!entities || !entities.length) {
|
if (!entities || !entities.length) {
|
||||||
return renderMessagePart(text, highlight, emojiSize, shouldRenderAsHtml, isSimple);
|
return renderMessagePart(text, highlight, emojiSize, shouldRenderAsHtml, isSimple);
|
||||||
@ -119,7 +120,8 @@ export function renderTextWithEntities(
|
|||||||
messageId,
|
messageId,
|
||||||
isSimple,
|
isSimple,
|
||||||
isProtected,
|
isProtected,
|
||||||
observeIntersection,
|
observeIntersectionForLoading,
|
||||||
|
observeIntersectionForPlaying,
|
||||||
emojiSize,
|
emojiSize,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -297,7 +299,8 @@ function processEntity(
|
|||||||
messageId?: number,
|
messageId?: number,
|
||||||
isSimple?: boolean,
|
isSimple?: boolean,
|
||||||
isProtected?: boolean,
|
isProtected?: boolean,
|
||||||
observeIntersection?: ObserveFn,
|
observeIntersectionForLoading?: ObserveFn,
|
||||||
|
observeIntersectionForPlaying?: ObserveFn,
|
||||||
emojiSize?: number,
|
emojiSize?: number,
|
||||||
) {
|
) {
|
||||||
const entityText = typeof entityContent === 'string' && entityContent;
|
const entityText = typeof entityContent === 'string' && entityContent;
|
||||||
@ -326,7 +329,8 @@ function processEntity(
|
|||||||
size={emojiSize}
|
size={emojiSize}
|
||||||
withSharedAnimation
|
withSharedAnimation
|
||||||
withGridFix={!emojiSize}
|
withGridFix={!emojiSize}
|
||||||
observeIntersection={observeIntersection}
|
observeIntersectionForLoading={observeIntersectionForLoading}
|
||||||
|
observeIntersectionForPlaying={observeIntersectionForPlaying}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -446,7 +450,8 @@ function processEntity(
|
|||||||
size={emojiSize}
|
size={emojiSize}
|
||||||
withSharedAnimation
|
withSharedAnimation
|
||||||
withGridFix={!emojiSize}
|
withGridFix={!emojiSize}
|
||||||
observeIntersection={observeIntersection}
|
observeIntersectionForLoading={observeIntersectionForLoading}
|
||||||
|
observeIntersectionForPlaying={observeIntersectionForPlaying}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -67,7 +67,7 @@ const AnimatedCustomEmoji: FC<OwnProps & StateProps> = ({
|
|||||||
size={size}
|
size={size}
|
||||||
withSharedAnimation
|
withSharedAnimation
|
||||||
forceOnHeavyAnimation
|
forceOnHeavyAnimation
|
||||||
observeIntersection={observeIntersection}
|
observeIntersectionForLoading={observeIntersection}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -530,6 +530,7 @@ const Message: FC<OwnProps & StateProps> = ({
|
|||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
isProtected,
|
isProtected,
|
||||||
|
observeIntersectionForMedia,
|
||||||
observeIntersectionForAnimatedStickers,
|
observeIntersectionForAnimatedStickers,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -959,7 +960,7 @@ const Message: FC<OwnProps & StateProps> = ({
|
|||||||
<CustomEmoji
|
<CustomEmoji
|
||||||
documentId={senderEmojiStatus.documentId}
|
documentId={senderEmojiStatus.documentId}
|
||||||
loopLimit={EMOJI_STATUS_LOOP_LIMIT}
|
loopLimit={EMOJI_STATUS_LOOP_LIMIT}
|
||||||
observeIntersection={observeIntersectionForMedia}
|
observeIntersectionForLoading={observeIntersectionForMedia}
|
||||||
observeIntersectionForPlaying={observeIntersectionForAnimatedStickers}
|
observeIntersectionForPlaying={observeIntersectionForAnimatedStickers}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -74,7 +74,7 @@ export function getMessageCopyOptions(
|
|||||||
document.execCommand('copy');
|
document.execCommand('copy');
|
||||||
} else {
|
} else {
|
||||||
const clipboardText = renderMessageText(
|
const clipboardText = renderMessageText(
|
||||||
message, undefined, undefined, undefined, undefined, undefined, undefined, true,
|
message, undefined, undefined, undefined, undefined, undefined, undefined, undefined, true,
|
||||||
);
|
);
|
||||||
if (clipboardText) copyHtmlToClipboard(clipboardText.join(''), getMessageTextWithSpoilers(message)!);
|
if (clipboardText) copyHtmlToClipboard(clipboardText.join(''), getMessageTextWithSpoilers(message)!);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ export function renderMessageSummaryHtml(
|
|||||||
const emoji = getMessageSummaryEmoji(message);
|
const emoji = getMessageSummaryEmoji(message);
|
||||||
const emojiWithSpace = emoji ? `${emoji} ` : '';
|
const emojiWithSpace = emoji ? `${emoji} ` : '';
|
||||||
const text = renderMessageText(
|
const text = renderMessageText(
|
||||||
message, undefined, undefined, undefined, undefined, undefined, undefined, true,
|
message, undefined, undefined, undefined, undefined, undefined, undefined, undefined, true,
|
||||||
)?.join('');
|
)?.join('');
|
||||||
const description = getMessageSummaryDescription(lang, message, text, true, true);
|
const description = getMessageSummaryDescription(lang, message, text, true, true);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user