component_web_image.go 809 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //go:build js && wasm
  2. package ultraviolet
  3. import (
  4. "syscall/js"
  5. )
  6. type ImageComponentWeb struct {
  7. node js.Value
  8. view View
  9. change bool
  10. path string
  11. }
  12. func NewImageComponentWeb(view View) *ImageComponentWeb {
  13. return &ImageComponentWeb{
  14. view: view,
  15. change: true,
  16. path: "",
  17. }
  18. }
  19. // Component
  20. func (this *ImageComponentWeb) Build(parent Component) {
  21. this.node = WebBuildImg(
  22. this.node,
  23. parent,
  24. this.view,
  25. this.path,
  26. )
  27. }
  28. func (this *ImageComponentWeb) Invalidate() bool {
  29. result := this.change
  30. this.change = false
  31. return result
  32. }
  33. func (this *ImageComponentWeb) Clean() {
  34. WebCleanChildren(this.node)
  35. }
  36. // JS
  37. func (this *ImageComponentWeb) Node() js.Value {
  38. return this.node
  39. }
  40. // ComponentImage
  41. func (this *ImageComponentWeb) SetPath(path string) {
  42. this.path = path
  43. }