A time-based spring class that moves its current value towards its target value if the two are ever different. The length and shape of the movement are determined by Seadragon.Config.animationTime and Seadragon.Config.springStiffness, respectively.
Note that while this class is time-based, the current value of the spring is only changed on calls to update(). Any calls to modifier methods will not reflect a changed current value until update() is called.
Signature | Description |
---|---|
Seadragon.Spring(initialValue) | Creates a spring with the given initial current and target value. |
Name and Signature | Return Type | Description |
---|---|---|
getCurrent() | Number | Returns the current value of the spring. |
getTarget() | Number | Returns the target value of the spring. |
resetTo(target) | - | Sets both the current and target values of the spring to the given value. |
shiftBy(delta) | - | Shifts both the current and target values of the spring by the given amount. |
springTo(target) | - | Sets the target value of the spring to the given value. |
update() | - | Updates the current value of the spring to move closer towards the target value. |