Skip to content

Commit 3fb46f7

Browse files
committed
Update progress manager
1 parent 1b67357 commit 3fb46f7

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/utils/ProgressManager.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,35 @@ const STEP_MS = 35
44
const MAX_VALUE = 1
55

66
export class ProgressManager {
7-
#autoplayDuration
8-
#onProgressValueChange
9-
10-
#interval
11-
#paused = false
12-
137
constructor({ onProgressValueChange }) {
14-
this.#onProgressValueChange = onProgressValueChange
8+
this._onProgressValueChange = onProgressValueChange
9+
10+
this._autoplayDuration
11+
this._onProgressValueChange
12+
13+
this._interval
14+
this._paused = false
1515
}
1616

1717
setAutoplayDuration(autoplayDuration) {
18-
this.#autoplayDuration = autoplayDuration
18+
this._autoplayDuration = autoplayDuration
1919
}
2020

2121
start(onFinish) {
2222
return new Promise((resolve) => {
2323
this.reset()
2424

25-
const stepMs = Math.min(STEP_MS, this.#autoplayDuration)
25+
const stepMs = Math.min(STEP_MS, this._autoplayDuration)
2626
let progress = -stepMs
2727

28-
this.#interval = setIntervalImmediate(async () => {
29-
if (this.#paused) {
28+
this._interval = setIntervalImmediate(async () => {
29+
if (this._paused) {
3030
return
3131
}
3232
progress += stepMs
3333

34-
const value = progress / this.#autoplayDuration
35-
this.#onProgressValueChange(value)
34+
const value = progress / this._autoplayDuration
35+
this._onProgressValueChange(value)
3636

3737
if (value > MAX_VALUE) {
3838
this.reset()
@@ -44,15 +44,15 @@ export class ProgressManager {
4444
}
4545

4646
pause() {
47-
this.#paused = true
47+
this._paused = true
4848
}
4949

5050
resume() {
51-
this.#paused = false
51+
this._paused = false
5252
}
5353

5454
reset() {
55-
clearInterval(this.#interval)
56-
this.#onProgressValueChange(MAX_VALUE)
55+
clearInterval(this._interval)
56+
this._onProgressValueChange(MAX_VALUE)
5757
}
5858
}

0 commit comments

Comments
 (0)