Skip to content

Instantly share code, notes, and snippets.

@JBirdVegas
Created May 25, 2021 15:48
Show Gist options
  • Save JBirdVegas/9c2b6aa16c71d906ecfdc5e0b8c9a83b to your computer and use it in GitHub Desktop.
Save JBirdVegas/9c2b6aa16c71d906ecfdc5e0b8c9a83b to your computer and use it in GitHub Desktop.
.loader {
position: absolute;
top: 50%;
left: 50%;
margin-left: -50px;
margin-top: -50px;
border: 16px solid #f3f3f3;
border-top: 16px solid #3498db;
border-radius: 50%;
width: 120px;
height: 120px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
package main
import (
"github.com/siongui/godom/wasm"
)
type LoadingSpinner struct {
Spinner wasm.Value
_timer int64
}
func NewSpinner() LoadingSpinner {
element := wasm.Document.CreateElement("div")
element.Set("className", "loader")
return LoadingSpinner{
Spinner: element,
_timer: 0,
}
}
func (s *LoadingSpinner) Show() {
wasm.Document.Get("body").Call("prepend", s.Spinner)
}
func (s *LoadingSpinner) Hide() {
wasm.Document.Get("body").Call("removeChild", s.Spinner)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment