Bugfix tray accordion

This commit is contained in:
Mattias Granlund 2023-07-01 17:26:03 +01:00
parent abe07c071c
commit 5f3aebd519

View File

@ -1,29 +1,9 @@
export function accordion(node: HTMLDivElement, isOpen: boolean) {
const initialHeight = node.offsetHeight;
node.style.height = isOpen ? 'auto' : '0';
node.style.overflow = 'hidden';
return {
update(isOpenInner: boolean) {
const animation = node.animate(
[
{
height: initialHeight + 'px',
overflow: 'visible'
},
{
height: 0,
overflow: 'hidden'
}
],
{ duration: 100, fill: 'both' }
);
animation.pause();
if (!isOpenInner) {
animation.play();
} else {
animation.reverse();
animation.play();
}
node.style.display = isOpenInner ? 'initial' : 'none';
}
};
}