perf: 略微优化了移动和修改大小时候的性能

渲染移动组件时位置由left、top修改为translate
This commit is contained in:
ferret 2024-04-02 15:22:37 +08:00
parent 04bc68c3ce
commit f6a132339a

View File

@ -6,8 +6,11 @@ export const useComponentStyle = (attr: AttrType, index: number) => {
if (!attr) return {}
const componentStyle = {
zIndex: index + 1,
left: `${attr.x}px`,
top: `${attr.y}px`
// left: `${attr.x}px`,
// top: `${attr.y}px`,
left: 0,
top: 0,
transform: `translate(${attr.x}px, ${attr.y}px)` // 替换成transform 优化渲染性能
}
return componentStyle
}
@ -56,8 +59,11 @@ export const usePointStyle = (
}
const style = {
left: `${newLeft}px`,
top: `${newTop}px`,
// left: `${newLeft}px`,
// top: `${newTop}px`,
left: 0,
top: 0,
transform: `translate(${newLeft - 3}px, ${newTop - 3}px)`, // 替换成transform 优化渲染性能
cursor: cursorResize[index] + '-resize'
}