From 6ca64f91bd889d280a04d8ad7fee74b46018d366 Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 4 Apr 2024 12:00:39 +0200 Subject: [PATCH] [SimplePrimitives] Avoid accordion animation for initially active sections --- .../Primitives/SimplePrimitives.fs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Aardvark.UI.Primitives/Primitives/SimplePrimitives.fs b/src/Aardvark.UI.Primitives/Primitives/SimplePrimitives.fs index c9028760..0d544958 100644 --- a/src/Aardvark.UI.Primitives/Primitives/SimplePrimitives.fs +++ b/src/Aardvark.UI.Primitives/Primitives/SimplePrimitives.fs @@ -671,15 +671,29 @@ module SimplePrimitives = | Some ch -> [ "channelActive", ch ] | _ -> [] + let isActive = + let set = + match input with + | AccordionInput.Multi (set, _) -> set |> ASet.toAVal |> AVal.force + | AccordionInput.Single (index, _) -> index |> AVal.force |> HashSet.single + | _ -> HashSet.empty + + fun i -> set |> HashSet.contains i + require dependencies ( onBoot' channels boot ( Incremental.div attributes <| AList.ofList [ - for (title, node) in sections do - div [clazz "title"] [ + let sections = Array.ofList sections + + for index = 0 to sections.Length - 1 do + let title, node = sections.[index] + let active = isActive index + + div [clazz "title"; if active then clazz "active"] [ i [clazz "dropdown icon"] [] title ] - div [clazz "content"] [ + div [clazz "content"; if active then clazz "active"] [ node ] ]