-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwindow.go
53 lines (39 loc) · 1.01 KB
/
window.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package tinydom
import "syscall/js"
type Window struct {
js.Value
}
var win = js.Global().Get("window")
func GetWindow() *Window {
return &Window{win}
}
func (w *Window) Location() *Location {
return &Location{w.Get("location")}
}
func (w *Window) Navigator() *Navigator {
return &Navigator{w.Get("navigator")}
}
func (w *Window) History() *History {
return &History{w.Get("history")}
}
func (w *Window) Alert(message string) {
w.Call("alert", message)
}
func (w *Window) PushState(state interface{}, title, URL string) {
w.Get("history").Call("pushState", state, title, URL)
}
func (w *Window) ReplaceState(state interface{}, title, URL string) {
w.Get("history").Call("replaceState", state, title, URL)
}
func (w *Window) PageXOffset() float64 {
return w.Get("pageXOffset").Float()
}
func (w *Window) PageYOffset() float64 {
return w.Get("pageYOffset").Float()
}
func (w *Window) ScrollX() float64 {
return w.Get("scrollX").Float()
}
func (w *Window) ScrollY() float64 {
return w.Get("scrollY").Float()
}