<aside>
</aside>
레이아웃 스레싱이란? requestAnimateFrame이란?
Layout
→ Paint
→ Composite
Layout
→ Paint
→ Composite
모두 다시 계산Composite
만 다시 계산 (GPU 가속)// 매 프레임마다 재계산 필요 (Layout + Paint + Composite)
element.style.left = `${x}px`;
element.style.top = `${y}px`;
// Composite만 재계산 (GPU 가속)
element.style.transform = `translate(${x}px, ${y}px)`;
직접 확인해보자. translate는 cpu를 약 14%, top/left는 약 20%를 사용한다.
Composite
만 발생한다.화면 기록 2024-11-24 오전 1.53.38.mov
top/left 로 했을때는 Layout
부터 발생한다.
다음과 같은 코드이며, 8방향 리사이징을 구현해야한다.
특히 위쪽 방향으로 리사이징할 때 position은 감소하고 size는 증가해야한다. 어떻게 구현해야 좋을까?
style={{
width: `${size.width}px`,
height: `${size.height}px`,
transform: `translate(${position.x}px, ${position.y}px)`,
zIndex,
}}
transform-origin
속성을 사용해 기준점을 변경하려 했다.