Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: various improvements #615

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/animated/AnimatedInterpolation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ export default class AnimatedInterpolation extends AnimatedArray<Animated>
range: number[] | InterpolationConfig | ((...args: any[]) => IpValue),
output?: (number | string)[]
): AnimatedInterpolation {
return new AnimatedInterpolation(this, range as number[], output!)
return new AnimatedInterpolation(this, range as number[], output)
}
}
11 changes: 11 additions & 0 deletions src/animated/AnimatedValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { InterpolationConfig } from '../types/interpolation'
import Animated from './Animated'
import AnimatedInterpolation from './AnimatedInterpolation'
import AnimatedProps from './AnimatedProps'
import { now } from './Globals'

/**
* Animated works by building a directed acyclic graph of dependencies
Expand Down Expand Up @@ -82,4 +83,14 @@ export default class AnimatedValue extends Animated implements SpringValue {
): AnimatedInterpolation {
return new AnimatedInterpolation(this, range as number[], output!)
}

public reset(isActive: boolean) {
this.startPosition = this.value
this.lastPosition = this.value
this.lastVelocity = isActive ? this.lastVelocity : undefined
this.lastTime = isActive ? this.lastTime : undefined
this.startTime = now()
this.done = false
this.animatedStyles.clear()
}
}
6 changes: 3 additions & 3 deletions src/animated/AnimatedValueArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import AnimatedValue from './AnimatedValue'

export default class AnimatedValueArray extends AnimatedArray<AnimatedValue>
implements SpringValue {
constructor(values: (string | number)[]) {
constructor(values: AnimatedValue[]) {
drcmda marked this conversation as resolved.
Show resolved Hide resolved
super()
this.payload = values.map(n => new AnimatedValue(n))
this.payload = values
}

public setValue(value: (string | number)[] | string | number, flush = true) {
Expand All @@ -29,6 +29,6 @@ export default class AnimatedValueArray extends AnimatedArray<AnimatedValue>
range: number[] | InterpolationConfig | ((...args: any[]) => any),
output?: (number | string)[]
): AnimatedInterpolation {
return new AnimatedInterpolation(this, range as number[], output!)
return new AnimatedInterpolation(this, range as number[], output)
}
}
Loading