component_web_frame.go 806 B

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