[Perf] Composer: Optimize sending animation

This commit is contained in:
Alexander Zinchuk 2021-07-15 03:02:54 +03:00
parent 02c91fb760
commit 2fca5568f2
3 changed files with 16 additions and 5 deletions

View File

@ -33,11 +33,6 @@ export const CUSTOM_BG_CACHE_NAME = 'tt-custom-bg';
export const LANG_CACHE_NAME = 'tt-lang-packs-v5';
export const ASSET_CACHE_NAME = 'tt-assets';
export const API_UPDATE_THROTTLE = 300;
export const API_THROTTLE_RESET_UPDATES = new Set([
'newMessage', 'newScheduledMessage', 'deleteMessages', 'deleteScheduledMessages', 'deleteHistory',
]);
export const DOWNLOAD_WORKERS = 16;
export const UPLOAD_WORKERS = 16;
@ -97,6 +92,12 @@ export const FAST_SMOOTH_MIN_DURATION = 250;
export const FAST_SMOOTH_MAX_DURATION = 600;
export const FAST_SMOOTH_SHORT_TRANSITION_MAX_DISTANCE = 500; // px
// Average duration of message sending animation
export const API_UPDATE_THROTTLE = Math.round((FAST_SMOOTH_MIN_DURATION + FAST_SMOOTH_MAX_DURATION) / 2);
export const API_THROTTLE_RESET_UPDATES = new Set([
'newMessage', 'newScheduledMessage', 'deleteMessages', 'deleteScheduledMessages', 'deleteHistory',
]);
export const STICKER_SIZE_INLINE_DESKTOP_FACTOR = 13;
export const STICKER_SIZE_INLINE_MOBILE_FACTOR = 11;
export const STICKER_SIZE_AUTH = 160;

View File

@ -108,6 +108,12 @@ function scrollWithJs(
path = Math.min(path, remainingPath);
}
if (path === 0) {
isAnimating = false;
return;
}
const target = container.scrollTop + path;
if (forceDuration === 0) {

View File

@ -37,6 +37,10 @@ function scrollWithJs(container: HTMLElement, left: number, duration: number) {
path = Math.min(path, remainingPath);
}
if (path === 0) {
return;
}
const target = container.scrollLeft + path;
if (duration === 0) {