[Perf] Transition: Avoid wildcard selector
This commit is contained in:
parent
289694c13b
commit
ac1033b673
@ -57,7 +57,7 @@
|
|||||||
// https://stackoverflow.com/questions/36247140/why-dont-flex-items-shrink-past-content-size
|
// https://stackoverflow.com/questions/36247140/why-dont-flex-items-shrink-past-content-size
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
|
||||||
> div {
|
> .Transition__slide {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
#Settings {
|
#Settings {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
> div {
|
> .Transition__slide {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|||||||
@ -452,7 +452,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.animating > div > & {
|
.Transition.animating > .Transition__slide > & {
|
||||||
&::-webkit-scrollbar {
|
&::-webkit-scrollbar {
|
||||||
width: 0;
|
width: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
> div {
|
> .Transition__slide {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@ -60,7 +60,7 @@
|
|||||||
// https://stackoverflow.com/questions/36247140/why-dont-flex-items-shrink-past-content-size
|
// https://stackoverflow.com/questions/36247140/why-dont-flex-items-shrink-past-content-size
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
|
||||||
> div {
|
> .Transition__slide {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
> div {
|
> .Transition__slide {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
.Transition {
|
.Transition {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
> * {
|
> .Transition__slide {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
animation-fill-mode: forwards !important;
|
animation-fill-mode: forwards !important;
|
||||||
transition: background-color 0.2s;
|
|
||||||
|
|
||||||
&.from,
|
&.from,
|
||||||
&.to {
|
&.to {
|
||||||
@ -35,7 +34,7 @@
|
|||||||
transform: translate3d(0, 0, 0);
|
transform: translate3d(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#root & > div {
|
#root & > .Transition__slide {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
display: block !important;
|
display: block !important;
|
||||||
top: 0;
|
top: 0;
|
||||||
@ -186,7 +185,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
&.mv-slide {
|
&.mv-slide {
|
||||||
> * > div {
|
> .Transition__slide > div {
|
||||||
animation-fill-mode: forwards !important;
|
animation-fill-mode: forwards !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,7 +350,7 @@
|
|||||||
--background-color: var(--color-background);
|
--background-color: var(--color-background);
|
||||||
background: black;
|
background: black;
|
||||||
|
|
||||||
> div {
|
> .Transition__slide {
|
||||||
background: var(--background-color);
|
background: var(--background-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,7 +391,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
&.push-slide {
|
&.push-slide {
|
||||||
> div {
|
> .Transition__slide {
|
||||||
background: var(--color-background);
|
background: var(--color-background);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import type { FC } from '../../lib/teact/teact';
|
|||||||
import React, { useLayoutEffect, useRef } from '../../lib/teact/teact';
|
import React, { useLayoutEffect, useRef } from '../../lib/teact/teact';
|
||||||
import { addExtraClass, removeExtraClass, toggleExtraClass } from '../../lib/teact/teact-dom';
|
import { addExtraClass, removeExtraClass, toggleExtraClass } from '../../lib/teact/teact-dom';
|
||||||
import { getGlobal } from '../../global';
|
import { getGlobal } from '../../global';
|
||||||
|
|
||||||
import type { GlobalState } from '../../global/types';
|
import type { GlobalState } from '../../global/types';
|
||||||
|
|
||||||
import { ANIMATION_LEVEL_MIN } from '../../config';
|
import { ANIMATION_LEVEL_MIN } from '../../config';
|
||||||
@ -40,6 +39,7 @@ export type TransitionProps = {
|
|||||||
|
|
||||||
const FALLBACK_ANIMATION_END = 1000;
|
const FALLBACK_ANIMATION_END = 1000;
|
||||||
const CLASSES = {
|
const CLASSES = {
|
||||||
|
slide: 'Transition__slide',
|
||||||
active: 'Transition__slide--active',
|
active: 'Transition__slide--active',
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -94,10 +94,15 @@ const Transition: FC<TransitionProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const container = containerRef.current!;
|
const container = containerRef.current!;
|
||||||
const childElements = container.children;
|
const childElements = Array.from(container.children) as HTMLElement[];
|
||||||
|
|
||||||
|
childElements.forEach((el) => {
|
||||||
|
addExtraClass(el, CLASSES.slide);
|
||||||
|
});
|
||||||
|
|
||||||
if (childElements.length === 1 && !activeKeyChanged) {
|
if (childElements.length === 1 && !activeKeyChanged) {
|
||||||
const firstChild = childElements[0] as HTMLElement;
|
const firstChild = childElements[0];
|
||||||
|
|
||||||
if (name.startsWith('slide-optimized')) {
|
if (name.startsWith('slide-optimized')) {
|
||||||
firstChild.style.transition = 'none';
|
firstChild.style.transition = 'none';
|
||||||
firstChild.style.transform = 'translate3d(0, 0, 0)';
|
firstChild.style.transform = 'translate3d(0, 0, 0)';
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// @optimization
|
// @optimization
|
||||||
@mixin while-transition() {
|
@mixin while-transition() {
|
||||||
.Transition > div:not(.Transition__slide--active) & {
|
.Transition__slide:not(.Transition__slide--active) & {
|
||||||
@content;
|
@content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
.MessageList,
|
.MessageList,
|
||||||
.messages-layout,
|
.messages-layout,
|
||||||
.Transition,
|
.Transition,
|
||||||
.Transition > * {
|
.Transition > .Transition__slide {
|
||||||
height: auto !important;
|
height: auto !important;
|
||||||
overflow: visible !important;
|
overflow: visible !important;
|
||||||
display: block !important;
|
display: block !important;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user