Motion
Interpolator between two values with duration
class Motion
Properties
Whether the interpolation is in active state.
Duration of the interpolation
Easing function of the interpolation
End(to) value of interpolation
Whether to loop interpolation on finish
Interpolation progress value (0 ~ 1)
Range of the interpolation
Start(from) value of interpolation
Current interpolated value
Methods
Add delta to start & end and current value.
Set start
, end
to the given value and set progress
to 0.
Set current value to start, and end to current value + delta, then reset progress to 0.
Set new range of the interpolation.
Update motion and progress it by given deltaTime
Constructor
new Motion(options: { duration: undefined | number; easing: undefined | ((x: number) => number); loop: undefined | boolean; range: undefined | { max: number; min: number } }): Motion
Parameters
{ duration: undefined | number; easing: undefined | ((x: number) => number); loop: undefined | boolean; range: undefined | { max: number; min: number } }
{}
Options
undefined | number
Duration of the interpolation
undefined | Function
undefined | boolean
Whether to loop interpolation on finish
undefined | Object
Range of the interpolation
Properties
activated
activatedboolean
Whether the interpolation is in active state.
duration
durationnumber
Duration of the interpolation
easing
easing((x: number) => number)
Easing function of the interpolation
end
endnumber
End(to) value of interpolation
loop
loopboolean
Whether to loop interpolation on finish
progress
progressnumber
Interpolation progress value (0 ~ 1)
range
rangeRange
Range of the interpolation
start
startnumber
Start(from) value of interpolation
val
valnumber
Current interpolated value
Methods
add
addvoid
add(delta: number): void
Add delta to start & end and current value.
Parameters
number
Delta value to add
reset
resetvoid
reset(defaultVal: number): void
Set start
, end
to the given value and set progress
to 0.
Parameters
number
Value to reset
setNewEndByDelta
setNewEndByDeltavoid
setNewEndByDelta(delta: number): void
Set current value to start, and end to current value + delta, then reset progress to 0.
Parameters
number
Delta value to add
setRange
setRangevoid
setRange(min: number, max: number): void
Set new range of the interpolation.
Parameters
number
New minimum range
number
New maximum range
update
updatenumber
update(deltaTime: number): number
Update motion and progress it by given deltaTime
Parameters
number
number of milisec to update motion
Returns
Difference(delta) of the value from the last update.