Skip to content

Commit

Permalink
CLeaning
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry committed Mar 15, 2024
1 parent 6fc5b28 commit f686add
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,45 +210,45 @@ export class AcceleratedAnimation<
}

get duration() {
const resolved = this.resolved
const { resolved } = this
if (!resolved) return 0
const { duration } = resolved
return millisecondsToSeconds(duration)
}

get time() {
const resolved = this.resolved
const { resolved } = this
if (!resolved) return 0
const { animation } = resolved
return millisecondsToSeconds((animation.currentTime as number) || 0)
}

set time(newTime: number) {
const resolved = this.resolved
const { resolved } = this
if (!resolved) return

const { animation } = resolved
animation.currentTime = secondsToMilliseconds(newTime)
}

get speed() {
const resolved = this.resolved
const { resolved } = this
if (!resolved) return 1

const { animation } = resolved
return animation.playbackRate
}

set speed(newSpeed: number) {
const resolved = this.resolved
const { resolved } = this
if (!resolved) return

const { animation } = resolved
animation.playbackRate = newSpeed
}

get state() {
const resolved = this.resolved
const { resolved } = this
if (!resolved) return "idle"

const { animation } = resolved
Expand All @@ -263,7 +263,7 @@ export class AcceleratedAnimation<
if (!this._resolved) {
this.pendingTimeline = timeline
} else {
const resolved = this.resolved
const { resolved } = this
if (!resolved) return noop<void>

const { animation } = resolved
Expand All @@ -277,15 +277,15 @@ export class AcceleratedAnimation<

play() {
if (this.isStopped) return
const resolved = this.resolved
const { resolved } = this
if (!resolved) return

const { animation } = resolved
animation.play()
}

pause() {
const resolved = this.resolved
const { resolved } = this
if (!resolved) return

const { animation } = resolved
Expand All @@ -294,7 +294,7 @@ export class AcceleratedAnimation<

stop() {
this.isStopped = true
const resolved = this.resolved
const { resolved } = this
if (!resolved) return

const { animation, keyframes } = resolved
Expand Down Expand Up @@ -334,13 +334,13 @@ export class AcceleratedAnimation<
}

complete() {
const resolved = this.resolved
const { resolved } = this
if (!resolved) return
resolved.animation.finish()
}

cancel() {
const resolved = this.resolved
const { resolved } = this
if (!resolved) return
resolved.animation.cancel()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class MainThreadAnimation<
}

tick(timestamp: number, sample = false) {
const resolved = this.resolved
const { resolved } = this

// If the animations has failed to resolve, return the final keyframe.
if (!resolved) {
Expand Down Expand Up @@ -395,7 +395,7 @@ export class MainThreadAnimation<
state: AnimationPlayState = "idle"

get duration() {
const resolved = this.resolved
const { resolved } = this
return resolved ? millisecondsToSeconds(resolved.calculatedDuration) : 0
}

Expand Down

0 comments on commit f686add

Please sign in to comment.