class Adw::SpringAnimation
- Adw::SpringAnimation
- Adw::Animation
- GObject::Object
- Reference
- Object
Overview
A spring-based #Animation
.
Adw::SpringAnimation
implements an animation driven by a physical model of a
spring described by #SpringParams
, with a resting position in
[property@SpringAnimation:value-to], stretched to
[property@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
[property@SpringAnimation:value-to] if
SpringAnimation::clamp
is set to TRUE
. The estimated duration can
be obtained with [property@SpringAnimation:estimated-duration].
Due to the nature of spring-driven motion the animation can overshoot
[property@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 [property@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.
Defined in:
lib/gi-crystal/src/auto/adw-1/spring_animation.crConstructors
-
.new(widget : Gtk::Widget, from : Float64, to : Float64, spring_params : Adw::SpringParams, target : Adw::AnimationTarget) : self
Creates a new
Adw::SpringAnimation
on @widget. -
.new
Initialize a new
SpringAnimation
. - .new(*, clamp : Bool? = nil, epsilon : Float64? = nil, estimated_duration : UInt32? = nil, initial_velocity : Float64? = nil, spring_params : Adw::SpringParams? = nil, state : Adw::AnimationState? = nil, target : Adw::AnimationTarget? = nil, value : Float64? = nil, value_from : Float64? = nil, value_to : Float64? = nil, velocity : Float64? = nil, widget : Gtk::Widget? = nil)
Class Method Summary
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
Instance Method Summary
-
#clamp : Bool
Gets whether @self should be clamped.
-
#clamp=(clamp : Bool) : Nil
Sets whether @self should be clamped.
- #clamp? : Bool
-
#epsilon : Float64
Gets the precision of the spring.
-
#epsilon=(epsilon : Float64) : Nil
Sets the precision of the spring.
-
#estimated_duration : UInt32
Gets the estimated duration of @self.
-
#initial_velocity : Float64
Gets the initial velocity of @self.
-
#initial_velocity=(velocity : Float64) : Nil
Sets the initial velocity of @self.
-
#spring_params : Adw::SpringParams
Gets the physical parameters of the spring of @self.
-
#spring_params=(spring_params : Adw::SpringParams) : Nil
Sets the physical parameters of the spring of @self.
-
#value_from : Float64
Gets the value @self will animate from.
-
#value_from=(value : Float64) : Nil
Sets the value @self will animate from.
-
#value_to : Float64
Gets the value @self will animate to.
-
#value_to=(value : Float64) : Nil
Sets the value @self will animate to.
-
#velocity : Float64
Gets the current velocity of @self.
Instance methods inherited from class Adw::Animation
done_signal
done_signal,
pause : Nil
pause,
play : Nil
play,
reset : Nil
reset,
resume : Nil
resume,
skip : Nil
skip,
state : Adw::AnimationState
state,
target : Adw::AnimationTarget
target,
target=(target : Adw::AnimationTarget) : Nil
target=,
value : Float64
value,
widget : Gtk::Widget
widget,
widget=(value : Gtk::Widget?) : Gtk::Widget?
widget=
Constructor methods inherited from class Adw::Animation
newnew(*, state : Adw::AnimationState? = nil, target : Adw::AnimationTarget? = nil, value : Float64? = nil, widget : Gtk::Widget? = nil) new
Class methods inherited from class Adw::Animation
g_type : UInt64
g_type
Instance methods inherited from class GObject::Object
bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding
bind_property,
bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding
bind_property_full,
data(key : String) : Pointer(Void)?
data,
finalize
finalize,
freeze_notify : Nil
freeze_notify,
getv(names : Enumerable(String), values : Enumerable(_)) : Nil
getv,
notify(property_name : String) : Nil
notify,
notify_by_pspec(pspec : GObject::ParamSpec) : Nil
notify_by_pspec,
notify_signal
notify_signal,
property(property_name : String, value : _) : Nil
property,
qdata(quark : UInt32) : Pointer(Void)?
qdata,
ref_count : UInt32
ref_count,
run_dispose : Nil
run_dispose,
set_data(key : String, data : Pointer(Void)?) : Nil
set_data,
set_property(property_name : String, value : _) : Nil
set_property,
steal_data(key : String) : Pointer(Void)?
steal_data,
steal_qdata(quark : UInt32) : Pointer(Void)?
steal_qdata,
thaw_notify : Nil
thaw_notify,
to_unsafe : Pointer(Void)
to_unsafe,
watch_closure(closure : GObject::Closure) : Nil
watch_closure
Constructor methods inherited from class GObject::Object
cast(obj : GObject::Object) : self
cast,
cast?(obj : GObject::Object) : self?
cast?,
new(pointer : Pointer(Void), transfer : GICrystal::Transfer)new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv
Class methods inherited from class GObject::Object
compat_control(what : UInt64, data : Pointer(Void)?) : UInt64
compat_control,
g_type : UInt64
g_type,
interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec
interface_find_property,
interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec)
interface_list_properties
Constructor Detail
Creates a new Adw::SpringAnimation
on @widget.
The animation will animate @target from @from to @to with the dynamics of a spring described by @spring_params.
Class Method Detail
Instance Method Detail
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 [property@SpringAnimation:value-from] if a relative negative [property@SpringAnimation:initial-velocity] is set.
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.
Gets the estimated duration of @self.
Can be #DURATION_INFINITE
if the spring damping is set to 0.
Sets the initial velocity of @self.
Initial velocity affects only the animation curve, but not its duration.
Sets the physical parameters of the spring of @self.
Sets the value @self will animate from.
The animation will start at this value and end at [property@SpringAnimation:value-to].
Sets the value @self will animate to.
The animation will start at [property@SpringAnimation:value-from] and end at this value.