fix double done event
This commit is contained in:
parent
e37c1ae568
commit
73ecde256b
@ -21,8 +21,8 @@ export const Menu =(props:{children:React.JSX.Element|React.JSX.Element[]})=>
|
|||||||
type MenuClassStates = {Keep:string, Open:string, Shut:string, Move:string, Exit:string};
|
type MenuClassStates = {Keep:string, Open:string, Shut:string, Move:string, Exit:string};
|
||||||
const Classes:MenuClassStates =
|
const Classes:MenuClassStates =
|
||||||
{
|
{
|
||||||
Keep: "relative transition-all border(8 black) top-0",
|
Keep: "relative transition-all border(8 black) ",
|
||||||
Open: "h-auto w-full top-0 duration-700",
|
Open: "h-auto w-1/2 top-8 duration-700",
|
||||||
Shut: "h-0 w-[300px] top-0 duration-300",
|
Shut: "h-0 w-[300px] top-0 duration-300",
|
||||||
Move: "",
|
Move: "",
|
||||||
Exit: "h-auto w-auto top-36 px-4 opacity-0"
|
Exit: "h-auto w-auto top-36 px-4 opacity-0"
|
||||||
@ -83,10 +83,11 @@ export function Collapser(inElement:HTMLElement, initialState = false)
|
|||||||
{
|
{
|
||||||
if (userMode)
|
if (userMode)
|
||||||
{
|
{
|
||||||
inElement.setAttribute("style", "");
|
inElement.setAttribute("style", "transition:none;");
|
||||||
|
inElement.clientHeight;
|
||||||
|
frameRequest = requestAnimationFrame(()=>{inElement.setAttribute("style", "")});
|
||||||
}
|
}
|
||||||
inTransition = false;
|
inTransition = false;
|
||||||
console.log("done", userMode);
|
|
||||||
userDone(userMode);
|
userDone(userMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,23 +128,19 @@ export function Collapser(inElement:HTMLElement, initialState = false)
|
|||||||
Open: keep + inElement.getAttribute("data-class-open"),
|
Open: keep + inElement.getAttribute("data-class-open"),
|
||||||
Shut: keep + inElement.getAttribute("data-class-shut"),
|
Shut: keep + inElement.getAttribute("data-class-shut"),
|
||||||
});
|
});
|
||||||
console.log(measurements);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inElement.style.overflow = "hidden";
|
inElement.style.overflow = "hidden";
|
||||||
inElement.style.width = inElement.offsetWidth + "px";
|
inElement.style.width = inElement.offsetWidth + "px";
|
||||||
inElement.style.height = inElement.offsetHeight + "px";
|
inElement.style.height = inElement.offsetHeight + "px";
|
||||||
|
|
||||||
|
|
||||||
inTransition = true;
|
inTransition = true;
|
||||||
console.log("from", inElement.offsetWidth, inElement.offsetHeight );
|
|
||||||
|
|
||||||
frameRequest = requestAnimationFrame(()=>
|
frameRequest = requestAnimationFrame(()=>
|
||||||
{
|
{
|
||||||
const measure = inOpen ? measurements.Open : measurements.Shut;
|
const measure = inOpen ? measurements.Open : measurements.Shut;
|
||||||
inElement.style.width = measure.width + "px";
|
inElement.style.width = measure.width + "px";
|
||||||
inElement.style.height = measure.height + "px";
|
inElement.style.height = measure.height + "px";
|
||||||
console.log(" to", measure.width, measure.height );
|
|
||||||
inElement.className = inElement.getAttribute("data-class-keep") + " " + inElement.getAttribute(`data-class-${inOpen?"open":"shut"}`);
|
inElement.className = inElement.getAttribute("data-class-keep") + " " + inElement.getAttribute(`data-class-${inOpen?"open":"shut"}`);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user