mirror of
https://github.com/status-im/whispervis.git
synced 2025-02-01 16:04:56 +00:00
19 lines
534 B
Go
19 lines
534 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/gopherjs/gopherjs/js"
|
||
|
"github.com/gopherjs/vecty"
|
||
|
)
|
||
|
|
||
|
// VisibilityListener implements listener for visibilitychange events.
|
||
|
// We use it to pause animation when the page is hidden, because WebGL
|
||
|
// animation is pretty CPU expensive.
|
||
|
// See https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API for details.
|
||
|
func (p *Page) VisibilityListener(e *vecty.Event) {
|
||
|
document := js.Global.Get("document")
|
||
|
hidden := document.Get("hidden")
|
||
|
fmt.Println("Page is hidden:", hidden)
|
||
|
}
|