Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaf8ebc2

Browse files
authored
Detect if Browser Tab is in the view
1 parent32cabe1 commitaf8ebc2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
|26|[getBoundingClientRect](#getBoundingClientRect)|
3333
|27|[Check if a node is in the viewport](#Check-if-a-node-is-in-the-viewport)|
3434
|28|[Notify when element size is changed](#Notify-when-element-size-is-changed)|
35+
|29|[Detect if Browser Tab is in the view](#Detect-if-Browser-Tab-is-in-the-view)|
3536

3637

3738

@@ -592,6 +593,23 @@ const observer = new ResizeObserver((entries) => {
592593
});
593594
observer.observe(foo);
594595

596+
```
597+
**[⬆ Back to Top](#table-of-contents)**
598+
### Detect if Browser Tab is in the view
599+
play/pause video accordingly
600+
see our codepen: https://codepen.io/JSsnippets/pen/gOapPzq
601+
```javascript
602+
603+
604+
constvideo=document.getElementById("my-video");
605+
606+
constonVisibilitychange=()=>{
607+
returndocument.hidden
608+
?video.pause()
609+
:video.play();
610+
}
611+
612+
document.addEventListener("visibilitychange", onVisibilitychange)
595613

596614
```
597615

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp