Skip to content

Commit

Permalink
change name to showAt and introduce showUntil and showFrom
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoGranstrom committed Nov 16, 2023
1 parent 9960246 commit a8d96c1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/nimiSlides/autoAnimation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@ template autoAnimateSlides*(nSlides: int, body: untyped) =
slide(slideOptions(autoAnimate=true)):
body

template showOn*(showOnSlides: varargs[set[range[0..65535]], toSet], body: untyped) = # how to auto convert to set like in varargs?
template showAt*(slideNrs: varargs[set[range[0..65535]], toSet], body: untyped) = # how to auto convert to set like in varargs?
# use vararg and union all results!
# This way you don't need to use the set syntax but can pass in `showOn(1, 2, 3)` instead.
var totalSet: set[range[0..65535]]
for x in showOnSlides:
for x in slideNrs:
totalSet.incl x

if autoAnimateCounter in totalSet:
body
# The if-statement will cause some troubles for some code if it assumes it will be run in the same scope :/
# To fix that we would need to require static inputs
# To fix that we would need to require static inputs

template showFrom*(slideNr: int, body: untyped) =
if autoAnimateCounter >= slideNr:
body

template showUntil*(slideNr: int, body: untyped) =
if autoAnimateCounter <= slideNr:
body

0 comments on commit a8d96c1

Please sign in to comment.