Browse Source

some fixes

master
Eduard Kuzmenko 2 years ago committed by r4sas
parent
commit
4b4f7c2191
  1. 2
      src/components/chat/bubbles.ts
  2. 2
      src/components/wrappers/sticker.ts
  3. 39
      src/lib/richTextProcessor/wrapRichText.ts

2
src/components/chat/bubbles.ts

@ -5276,7 +5276,7 @@ export default class ChatBubbles { @@ -5276,7 +5276,7 @@ export default class ChatBubbles {
const mids = invisible.map(({element}) => +element.dataset.mid);
let scrollSaver: ScrollSaver;
if(!!invisibleTop.length !== !!invisibleBottom.length && !ignoreScrollSaving) {
if(/* !!invisibleTop.length !== !!invisibleBottom.length && */!ignoreScrollSaving) {
scrollSaver = this.createScrollSaver(!!invisibleTop.length);
scrollSaver.save();
}

2
src/components/wrappers/sticker.ts

@ -713,7 +713,7 @@ export async function onEmojiStickerClick({event, container, managers, peerId, m @@ -713,7 +713,7 @@ export async function onEmojiStickerClick({event, container, managers, peerId, m
doc,
middleware,
side: isOut ? 'right' : 'left',
size: 280,
size: 360,
target: container,
play: true,
withRandomOffset: true

39
src/lib/richTextProcessor/wrapRichText.ts

@ -23,12 +23,12 @@ import IS_CUSTOM_EMOJI_SUPPORTED from '../../environment/customEmojiSupport'; @@ -23,12 +23,12 @@ import IS_CUSTOM_EMOJI_SUPPORTED from '../../environment/customEmojiSupport';
import rootScope from '../rootScope';
import mediaSizes from '../../helpers/mediaSizes';
import {wrapSticker} from '../../components/wrappers';
import RLottiePlayer, {getLottiePixelRatio} from '../rlottie/rlottiePlayer';
import RLottiePlayer from '../rlottie/rlottiePlayer';
import animationIntersector from '../../components/animationIntersector';
import type {MyDocument} from '../appManagers/appDocsManager';
import LazyLoadQueue from '../../components/lazyLoadQueue';
import {Awaited} from '../../types';
import sequentialDom from '../../helpers/sequentialDom';
// import sequentialDom from '../../helpers/sequentialDom';
import {MediaSize} from '../../helpers/mediaSize';
import IS_WEBM_SUPPORTED from '../../environment/webmSupport';
@ -56,6 +56,9 @@ export class CustomEmojiRendererElement extends HTMLElement { @@ -56,6 +56,9 @@ export class CustomEmojiRendererElement extends HTMLElement {
public middleware: () => boolean;
public keys: string[];
public lastRect: DOMRect;
public isDimensionsSet: boolean;
constructor() {
super();
@ -126,7 +129,11 @@ export class CustomEmojiRendererElement extends HTMLElement { @@ -126,7 +129,11 @@ export class CustomEmojiRendererElement extends HTMLElement {
}
public render(offsetsMap: ReturnType<CustomEmojiRendererElement['getOffsets']>) {
const {context, canvas} = this;
const {context, canvas, isDimensionsSet} = this;
if(!isDimensionsSet) {
this.setDimensionsFromRect();
}
const {width, height, dpr} = canvas;
for(const [containers, player] of this.players) {
const frame = topFrames.get(player);
@ -186,17 +193,27 @@ export class CustomEmojiRendererElement extends HTMLElement { @@ -186,17 +193,27 @@ export class CustomEmojiRendererElement extends HTMLElement {
this.canvas.remove();
}
public setDimensions() {
// public setDimensions() {
// const {canvas} = this;
// sequentialDom.mutateElement(canvas, () => {
// const rect = canvas.getBoundingClientRect();
// this.setDimensionsFromRect(rect);
// });
// }
public setDimensionsFromRect(rect: DOMRect = this.lastRect) {
const {canvas} = this;
sequentialDom.mutateElement(canvas, () => {
const rect = canvas.getBoundingClientRect();
this.setDimensionsFromRect(rect);
});
const {dpr} = canvas;
if(this.lastRect !== rect) {
this.lastRect = rect;
}
public setDimensionsFromRect(rect: DOMRect) {
const {canvas} = this;
const dpr = canvas.dpr ??= getLottiePixelRatio(rect.width, rect.height);
if(!rect || !dpr) {
return;
}
this.isDimensionsSet = true;
canvas.width = Math.round(rect.width * dpr);
canvas.height = Math.round(rect.height * dpr);
}

Loading…
Cancel
Save