carousel is now a real example
This commit is contained in:
parent
d9648be60c
commit
a535ad709b
5 changed files with 4 additions and 10 deletions
|
|
@ -5,7 +5,7 @@ import vdom, vstyles, karax, karaxdsl, jdict, jstrutils, kdom
|
||||||
type
|
type
|
||||||
Carousel = ref object of VComponent
|
Carousel = ref object of VComponent
|
||||||
counter: int
|
counter: int
|
||||||
cntdown, myid: int
|
cntdown: int
|
||||||
timer: TimeOut
|
timer: TimeOut
|
||||||
list: seq[cstring]
|
list: seq[cstring]
|
||||||
|
|
||||||
|
|
@ -44,21 +44,14 @@ proc render(x: VComponent): VNode =
|
||||||
button(onclick = onclick):
|
button(onclick = onclick):
|
||||||
text "Next"
|
text "Next"
|
||||||
tdiv(style = style(StyleAttr.color, col)):
|
tdiv(style = style(StyleAttr.color, col)):
|
||||||
text "This changes its color." & &self.myid
|
text "This changes its color."
|
||||||
if self.cntdown != ticksUntilChange:
|
if self.cntdown != ticksUntilChange:
|
||||||
text &self.cntdown
|
text &self.cntdown
|
||||||
|
|
||||||
var gid: int
|
|
||||||
|
|
||||||
proc carousel(): Carousel =
|
proc carousel(): Carousel =
|
||||||
result = newComponent(Carousel, render)
|
result = newComponent(Carousel, render)
|
||||||
result.list = images
|
result.list = images
|
||||||
result.cntdown = ticksUntilChange
|
result.cntdown = ticksUntilChange
|
||||||
result.myid = gid
|
|
||||||
inc gid
|
|
||||||
#result.onAttach = proc (_: VComponent) =
|
|
||||||
# result.cntdown = ticksUntilChange
|
|
||||||
# kout cstring"attached!"
|
|
||||||
|
|
||||||
proc createDom(): VNode =
|
proc createDom(): VNode =
|
||||||
result = buildHtml(table):
|
result = buildHtml(table):
|
||||||
1
examples/carousel/carousel.nims
Normal file
1
examples/carousel/carousel.nims
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
--path: "../../src"
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
--path: "../src"
|
|
||||||
|
|
@ -11,5 +11,6 @@ proc main =
|
||||||
exec("nim js examples/todoapp/todoapp.nim")
|
exec("nim js examples/todoapp/todoapp.nim")
|
||||||
exec("nim js examples/scrollapp/scrollapp.nim")
|
exec("nim js examples/scrollapp/scrollapp.nim")
|
||||||
exec("nim js examples/mediaplayer/playerapp.nim")
|
exec("nim js examples/mediaplayer/playerapp.nim")
|
||||||
|
exec("nim js examples/carousel/carousel.nim")
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue