carousel is now a real example

This commit is contained in:
Andreas Rumpf 2017-06-21 17:57:02 +02:00
commit a535ad709b
5 changed files with 4 additions and 10 deletions

View file

@ -5,7 +5,7 @@ import vdom, vstyles, karax, karaxdsl, jdict, jstrutils, kdom
type
Carousel = ref object of VComponent
counter: int
cntdown, myid: int
cntdown: int
timer: TimeOut
list: seq[cstring]
@ -44,21 +44,14 @@ proc render(x: VComponent): VNode =
button(onclick = onclick):
text "Next"
tdiv(style = style(StyleAttr.color, col)):
text "This changes its color." & &self.myid
text "This changes its color."
if self.cntdown != ticksUntilChange:
text &self.cntdown
var gid: int
proc carousel(): Carousel =
result = newComponent(Carousel, render)
result.list = images
result.cntdown = ticksUntilChange
result.myid = gid
inc gid
#result.onAttach = proc (_: VComponent) =
# result.cntdown = ticksUntilChange
# kout cstring"attached!"
proc createDom(): VNode =
result = buildHtml(table):

View file

@ -0,0 +1 @@
--path: "../../src"

View file

@ -1 +0,0 @@
--path: "../src"

View file

@ -11,5 +11,6 @@ proc main =
exec("nim js examples/todoapp/todoapp.nim")
exec("nim js examples/scrollapp/scrollapp.nim")
exec("nim js examples/mediaplayer/playerapp.nim")
exec("nim js examples/carousel/carousel.nim")
main()