From cfdad6105815f3c892699d6e5277d8725482de4e Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Tue, 30 May 2023 10:17:22 -0400 Subject: [PATCH] remove RAF in transitionend --- example/tree-menu.tsx | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/example/tree-menu.tsx b/example/tree-menu.tsx index aaafd23..5f3bca8 100644 --- a/example/tree-menu.tsx +++ b/example/tree-menu.tsx @@ -121,7 +121,6 @@ const useAway =(inRef:React.Ref, handleAway:Handler)=> , []); }; - type StyleSize = [classes:string, width:number, height:number]; type StylePack = Record; type StyleCalc = Record; @@ -171,12 +170,9 @@ export function Collapser(inElement:HTMLElement, initialState:string, library:Re } else { - frameRequest = requestAnimationFrame(()=> - { - inElement.setAttribute("style", ""); - inTransition = false; - userDone(userMode); - }); + inElement.setAttribute("style", ""); + inTransition = false; + userDone(userMode); } } } @@ -199,19 +195,19 @@ export function Collapser(inElement:HTMLElement, initialState:string, library:Re if(measurements) { - const [classes, width, height] = measurements[inState] as StyleSize; - const oldWidth = inElement.offsetWidth; - const oldHeight = inElement.offsetHeight; - inElement.style.width = oldWidth + "px"; - inElement.style.height = oldHeight + "px"; - inTransition = true; + const [classes, width, height] = measurements[inState] as StyleSize; + const oldWidth = inElement.offsetWidth; + const oldHeight = inElement.offsetHeight; + inElement.style.width = oldWidth + "px"; + inElement.style.height = oldHeight + "px"; + inTransition = true; - frameRequest = requestAnimationFrame(()=> - { - inElement.style.height = height + "px"; - inElement.style.width = width + "px"; - inElement.className = classes; - }); + frameRequest = requestAnimationFrame(()=> + { + inElement.style.height = height + "px"; + inElement.style.width = width + "px"; + inElement.className = classes; + }); } } else