-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor and implement autoAnimateSlides template * change name to showAt and introduce showUntil and showFrom * save progress * write auto-animate docs * update to reveal.js version 5.0.4
- Loading branch information
1 parent
cbecb1e
commit c9e80b9
Showing
4 changed files
with
142 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import std/[strutils] | ||
import nimib | ||
import ./[conversions] | ||
|
||
template autoAnimateSlides*(nSlides: int, body: untyped) = | ||
for autoAnimateCounter {.inject.} in 1 .. nSlides: | ||
slide(slideOptions(autoAnimate=true)): | ||
body | ||
|
||
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 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 | ||
|
||
template showFrom*(slideNr: int, body: untyped) = | ||
if autoAnimateCounter >= slideNr: | ||
body | ||
|
||
template showUntil*(slideNr: int, body: untyped) = | ||
if autoAnimateCounter <= slideNr: | ||
body | ||
|
||
template showText*(text: seq[(set[range[0..255]], string)]) = | ||
var result = "" | ||
for i, (indices, txt) in text: | ||
if indices == {} or autoAnimateCounter in indices: | ||
result &= "<span data-id=\"autoAnimateId-$1\">" % [$i] & txt & "</span>" | ||
nbText: result | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
proc toHSlice*(h: HSlice[int, int]): HSlice[int, int] = h | ||
proc toHSlice*(h: int): HSlice[int, int] = h .. h | ||
|
||
|
||
proc toSet*(x: set[range[0..65535]]): set[range[0..65535]] = x | ||
proc toSet*(x: int): set[range[0..65535]] = {x} | ||
proc toSet*(x: Slice[int]): set[range[0..65535]] = | ||
for y in x: | ||
result.incl y | ||
proc toSet*(x: seq[Slice[int]]): set[range[0..65535]] = | ||
for s in x: | ||
result.incl s.toSet() | ||
proc toSet*(x: set[range[0..255]]): set[range[0..65535]] = | ||
for y in x: | ||
result.incl y |