Skip to content

Commit

Permalink
[SimplePrimitives] Avoid accordion animation for initially active sec…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
hyazinthh committed Apr 4, 2024
1 parent 48538eb commit 6ca64f9
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Aardvark.UI.Primitives/Primitives/SimplePrimitives.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
]
Expand Down

0 comments on commit 6ca64f9

Please sign in to comment.