Skip to content

Commit 9c01215

Browse files
authored
Timer: Add usePageVisibilityAPI ctor parameter. (mrdoob#30522)
1 parent b1d7cdc commit 9c01215

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

docs/examples/en/misc/Timer.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ <h2>Examples</h2>
6060

6161
<h2>Constructor</h2>
6262

63-
<h3>Timer()</h3>
63+
<h3>Timer( [param:Boolean usePageVisibilityAPI] )</h3>
64+
<p>
65+
[page:Boolean usePageVisibilityAPI] - (optional) Whether to use the Page Visibility API to avoid large time delta values in inactive tabs or not. Default is `true`.
66+
</p>
6467

6568
<h2>Methods</h2>
6669

examples/jsm/misc/Timer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Timer {
22

3-
constructor() {
3+
constructor( usePageVisibilityAPI = true ) {
44

55
this._previousTime = 0;
66
this._currentTime = 0;
@@ -13,7 +13,7 @@ class Timer {
1313

1414
// use Page Visibility API to avoid large time delta values
1515

16-
this._usePageVisibilityAPI = ( typeof document !== 'undefined' && document.hidden !== undefined );
16+
this._usePageVisibilityAPI = ( usePageVisibilityAPI === true ) && ( typeof document !== 'undefined' && document.hidden !== undefined );
1717

1818
if ( this._usePageVisibilityAPI === true ) {
1919

0 commit comments

Comments
 (0)