Window Focus
Reactive window focus.
Usage
<script>
import { windowFocus } from "@sveu/browser"
const focused = windowFocus()
</script>
<script>
import { windowFocus } from "@sveu/browser"
const focused = windowFocus()
</script>
svelte
Example
ℹ Tab is unfocused
<script>
import { windowFocus } from "@sveu/browser"
const focused = windowFocus()
const start_message =
"💡 Click somewhere outside of the document to unfocus."
let message = start_message
$: if (!$focused) {
message = "ℹ Tab is unfocused"
} else {
message = start_message
}
</script>
<h1 class="text-center">{message}</h1>
<script>
import { windowFocus } from "@sveu/browser"
const focused = windowFocus()
const start_message =
"💡 Click somewhere outside of the document to unfocus."
let message = start_message
$: if (!$focused) {
message = "ℹ Tab is unfocused"
} else {
message = start_message
}
</script>
<h1 class="text-center">{message}</h1>
svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Click fold/expand code