diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-04-24 20:13:17 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-04-24 20:13:17 +0200 |
commit | 833390a649c633892fbc0d9b6e37d6f7913cabb1 (patch) | |
tree | afe334494ef1ab5265ed53d4f48e6fe389b532ef /src/main/kotlin/pl/treksoft/kvision/html | |
parent | 7bc2dce08659b7cbcb3fd1865c7e3d95e8c42c52 (diff) | |
download | kvision-833390a649c633892fbc0d9b6e37d6f7913cabb1.tar.gz kvision-833390a649c633892fbc0d9b6e37d6f7913cabb1.tar.bz2 kvision-833390a649c633892fbc0d9b6e37d6f7913cabb1.zip |
Fix various problems with re-creating DOM nodes.
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Canvas.kt | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Canvas.kt b/src/main/kotlin/pl/treksoft/kvision/html/Canvas.kt index 450042a2..476ee118 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Canvas.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Canvas.kt @@ -53,6 +53,10 @@ open class Canvas( */ lateinit var context2D: CanvasRenderingContext2D + init { + this.vnkey = "kv_canvas_${counter++}" + } + override fun render(): VNode { return render("canvas") } @@ -68,11 +72,14 @@ open class Canvas( return pr } - override fun afterInsert(node: VNode) { + override fun afterInsertInternal(node: VNode) { + super.afterInsertInternal(node) context2D = (node.elm as HTMLCanvasElement).getContext("2d") as CanvasRenderingContext2D } companion object { + internal var counter = 0 + /** * DSL builder extension function. * |