1.56 <AdwSpringAnimation>

Class: <AdwSpringAnimation>

It derives from <AdwAnimation>.

A spring-based Animation.

<AdwSpringAnimation> implements an animation driven by a physical model of a spring described by SpringParams, with a resting position in SpringAnimation:value-to, stretched to SpringAnimation:value-from.

Since the animation is physically simulated, spring animations don’t have a fixed duration. The animation will stop when the simulated spring comes to a rest - when the amplitude of the oscillations becomes smaller than SpringAnimation:epsilon, or immediately when it reaches SpringAnimation:value-to if SpringAnimation:clamp is set to TRUE. The estimated duration can be obtained with SpringAnimation:estimated-duration.

Due to the nature of spring-driven motion the animation can overshoot SpringAnimation:value-to before coming to a rest. Whether the animation will overshoot or not depends on the damping ratio of the spring. See SpringParams for more information about specific damping ratio values.

If SpringAnimation:clamp is TRUE, the animation will abruptly end as soon as it reaches the final value, preventing overshooting.

Animations can have an initial velocity value, set via SpringAnimation:initial-velocity, which adjusts the curve without changing the duration. This makes spring animations useful for deceleration at the end of gestures.

If the initial and final values are equal, and the initial velocity is not 0, the animation value will bounce and return to its resting position.

Properties

Property: spring-animation:clamp self

Whether the animation should be clamped.

If set to TRUE, the animation will abruptly end as soon as it reaches the final value, preventing overshooting.

It won’t prevent overshooting SpringAnimation:value-from if a relative negative SpringAnimation:initial-velocity is set.

Its value is a boolean.

Set it with (set! (spring-animation:clamp self) value).

Property: spring-animation:epsilon self

Precision of the spring.

The level of precision used to determine when the animation has come to a rest, that is, when the amplitude of the oscillations becomes smaller than this value.

If the epsilon value is too small, the animation will take a long time to stop after the animated value has stopped visibly changing.

If the epsilon value is too large, the animation will end prematurely.

The default value is 0.001.

Its value is a real number.

Set it with (set! (spring-animation:epsilon self) value).

Property: spring-animation:estimated-duration self

Estimated duration of the animation, in milliseconds.

Can be DURATION_INFINITE if the spring damping is set to 0.

Its value is an unsigned 32-bit integer.

It is read only.

Property: spring-animation:initial-velocity self

The initial velocity to start the animation with.

Initial velocity affects only the animation curve, but not its duration.

Its value is a real number.

Set it with (set! (spring-animation:initial-velocity self) value).

Property: spring-animation:spring-params self

Physical parameters describing the spring.

Its value is a <AdwSpringParams>, or #f.

Set it with (set! (spring-animation:spring-params self) value).

Property: spring-animation:value-from self

The value to animate from.

The animation will start at this value and end at SpringAnimation:value-to.

Its value is a real number.

Set it with (set! (spring-animation:value-from self) value).

Property: spring-animation:value-to self

The value to animate to.

The animation will start at SpringAnimation:value-from and end at this value.

Its value is a real number.

Set it with (set! (spring-animation:value-to self) value).

Property: spring-animation:velocity self

Current velocity of the animation.

Its value is a real number.

It is read only.

Procedures

Method: spring-animation:calculate-value self time ⇒ %return
Method: calculate-value self time ⇒ %return

Calculates the value self will have at time.

The time starts at 0 and ends at SpringAnimation:estimated_duration.

See also SpringAnimation.calculate_velocity.

self

Passed: a <AdwSpringAnimation>.

a spring animation

time

Passed: an unsigned 32-bit integer.

elapsed time, in milliseconds

%return

Returned: a real number.

the value at time

Method: spring-animation:calculate-velocity self time ⇒ %return
Method: calculate-velocity self time ⇒ %return

Calculates the velocity self will have at time.

The time starts at 0 and ends at SpringAnimation:estimated_duration.

See also SpringAnimation.calculate_value.

self

Passed: a <AdwSpringAnimation>.

a spring animation

time

Passed: an unsigned 32-bit integer.

elapsed time, in milliseconds

%return

Returned: a real number.

the velocity at time

Method: spring-animation:get-clamp? self ⇒ %return
Method: get-clamp? self ⇒ %return

Gets whether self should be clamped.

self

Passed: a <AdwSpringAnimation>.

a spring animation

%return

Returned: a boolean.

whether self is clamped

Method: spring-animation:get-epsilon self ⇒ %return
Method: get-epsilon self ⇒ %return

Gets the precision of the spring.

self

Passed: a <AdwSpringAnimation>.

a spring animation

%return

Returned: a real number.

the epsilon value

Method: spring-animation:get-estimated-duration self ⇒ %return
Method: get-estimated-duration self ⇒ %return

Gets the estimated duration of self, in milliseconds.

Can be DURATION_INFINITE if the spring damping is set to 0.

self

Passed: a <AdwSpringAnimation>.

a spring animation

%return

Returned: an unsigned 32-bit integer.

the estimated duration

Method: spring-animation:get-initial-velocity self ⇒ %return
Method: get-initial-velocity self ⇒ %return

Gets the initial velocity of self.

self

Passed: a <AdwSpringAnimation>.

a spring animation

%return

Returned: a real number.

the initial velocity

Method: spring-animation:get-spring-params self ⇒ %return
Method: get-spring-params self ⇒ %return

Gets the physical parameters of the spring of self.

self

Passed: a <AdwSpringAnimation>.

a spring animation

%return

Returned: a <AdwSpringParams>.

the spring parameters

Method: spring-animation:get-value-from self ⇒ %return
Method: get-value-from self ⇒ %return

Gets the value self will animate from.

self

Passed: a <AdwSpringAnimation>.

a spring animation

%return

Returned: a real number.

the value to animate from

Method: spring-animation:get-value-to self ⇒ %return
Method: get-value-to self ⇒ %return

Gets the value self will animate to.

self

Passed: a <AdwSpringAnimation>.

a spring animation

%return

Returned: a real number.

the value to animate to

Method: spring-animation:get-velocity self ⇒ %return
Method: get-velocity self ⇒ %return

Gets the current velocity of self.

self

Passed: a <AdwSpringAnimation>.

a spring animation

%return

Returned: a real number.

the current velocity

Procedure: spring-animation:new widget from to spring-params target ⇒ %return

Creates a new <AdwSpringAnimation> on widget.

The animation will animate target from from to to with the dynamics of a spring described by spring-params.

widget

Passed: a <GtkWidget>.

a widget to create animation on

from

Passed: a real number.

a value to animate from

to

Passed: a real number.

a value to animate to

spring-params

Passed: a <AdwSpringParams>.

physical parameters of the spring

target

Passed: a <AdwAnimationTarget>.

a target value to animate

%return

Returned: a <AdwAnimation>.

the newly created animation

Method: spring-animation:set-clamp self clamp
Method: set-clamp self clamp

Sets whether self should be clamped.

If set to TRUE, the animation will abruptly end as soon as it reaches the final value, preventing overshooting.

It won’t prevent overshooting SpringAnimation:value-from if a relative negative SpringAnimation:initial-velocity is set.

self

Passed: a <AdwSpringAnimation>.

a spring animation

clamp

Passed: a boolean.

the new value

Method: spring-animation:set-epsilon self epsilon
Method: set-epsilon self epsilon

Sets the precision of the spring.

The level of precision used to determine when the animation has come to a rest, that is, when the amplitude of the oscillations becomes smaller than this value.

If the epsilon value is too small, the animation will take a long time to stop after the animated value has stopped visibly changing.

If the epsilon value is too large, the animation will end prematurely.

The default value is 0.001.

self

Passed: a <AdwSpringAnimation>.

a spring animation

epsilon

Passed: a real number.

the new value

Method: spring-animation:set-initial-velocity self velocity
Method: set-initial-velocity self velocity

Sets the initial velocity of self.

Initial velocity affects only the animation curve, but not its duration.

self

Passed: a <AdwSpringAnimation>.

a spring animation

velocity

Passed: a real number.

the initial velocity

Method: spring-animation:set-spring-params self spring-params
Method: set-spring-params self spring-params

Sets the physical parameters of the spring of self.

self

Passed: a <AdwSpringAnimation>.

a spring animation

spring-params

Passed: a <AdwSpringParams>.

the new spring parameters

Method: spring-animation:set-value-from self value
Method: set-value-from self value

Sets the value self will animate from.

The animation will start at this value and end at SpringAnimation:value-to.

self

Passed: a <AdwSpringAnimation>.

a spring animation

value

Passed: a real number.

the value to animate from

Method: spring-animation:set-value-to self value
Method: set-value-to self value

Sets the value self will animate to.

The animation will start at SpringAnimation:value-from and end at this value.

self

Passed: a <AdwSpringAnimation>.

a spring animation

value

Passed: a real number.

the value to animate to