refactor: potential perf improvement for pane gesture

This commit is contained in:
Aman Harwara
2023-02-09 15:01:32 +05:30
parent 73adcd2e11
commit 3c068656e0
2 changed files with 2 additions and 6 deletions

View File

@@ -42,9 +42,6 @@ export async function animatePaneExitTransitionOffscreenToTheRight(elementId: st
const animation = element.animate(
[
{
transform: 'translateX(0)',
},
{
transform: 'translateX(100%)',
},

View File

@@ -89,11 +89,10 @@ export const usePaneSwipeGesture = (
overlayElementRef.current = overlayElement
}
const currentLeft = parseInt(element.style.left || '0')
const newLeft = direction === 'right' ? Math.max(x, 0) : Math.min(x, 0)
element.style.left = `${newLeft}px`
element.animate([{ transform: `translate3d(${newLeft}px,0,0)` }], { duration: 0, fill: 'forwards' })
const percent = Math.min(window.innerWidth / currentLeft / 10, 0.45)
const percent = Math.min(window.innerWidth / newLeft / 10, 0.45)
overlayElementRef.current.animate([{ opacity: percent }], {
duration: 0,
fill: 'forwards',