:right-sidebar: True SpringAnimation =================================================================== .. currentmodule:: gi.repository.Adw .. class:: SpringAnimation(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Adw.Animation`, :class:`~gi.repository.GObject.Object` A spring-based :obj:`~gi.repository.Adw.Animation`\. ``AdwSpringAnimation`` implements an animation driven by a physical model of a spring described by :obj:`~gi.repository.Adw.SpringParams`\, with a resting position in :obj:`~gi.repository.Adw.SpringAnimation.props.value_to`\, stretched to :obj:`~gi.repository.Adw.SpringAnimation.props.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 :obj:`~gi.repository.Adw.SpringAnimation.props.epsilon`\, or immediately when it reaches :obj:`~gi.repository.Adw.SpringAnimation.props.value_to` if :obj:`~gi.repository.Adw.SpringAnimation.props.clamp` is set to ``TRUE``\. The estimated duration can be obtained with :obj:`~gi.repository.Adw.SpringAnimation.props.estimated_duration`\. Due to the nature of spring-driven motion the animation can overshoot :obj:`~gi.repository.Adw.SpringAnimation.props.value_to` before coming to a rest. Whether the animation will overshoot or not depends on the damping ratio of the spring. See :obj:`~gi.repository.Adw.SpringParams` for more information about specific damping ratio values. If :obj:`~gi.repository.Adw.SpringAnimation.props.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 :obj:`~gi.repository.Adw.SpringAnimation.props.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. Constructors ------------ .. rst-class:: interim-class .. class:: SpringAnimation :no-index: .. classmethod:: new(widget: ~gi.repository.Gtk.Widget, from_: float, to: float, spring_params: ~gi.repository.Adw.SpringParams, target: ~gi.repository.Adw.AnimationTarget) -> ~gi.repository.Adw.Animation 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``\. :param widget: a widget to create animation on :param from_: :param to: a value to animate to :param spring_params: physical parameters of the spring :param target: a target value to animate Methods ------- .. rst-class:: interim-class .. class:: SpringAnimation :no-index: .. method:: calculate_value(time: int) -> float Calculates the value ``self`` will have at ``time``\. The time starts at 0 and ends at :obj:`~gi.repository.Adw.SpringAnimation.props.estimated_duration`\. See also :obj:`~gi.repository.SpringAnimation.calculate_velocity`\. .. versionadded:: 1.3 :param time: elapsed time, in milliseconds .. method:: calculate_velocity(time: int) -> float Calculates the velocity ``self`` will have at ``time``\. The time starts at 0 and ends at :obj:`~gi.repository.Adw.SpringAnimation.props.estimated_duration`\. See also :obj:`~gi.repository.SpringAnimation.calculate_value`\. .. versionadded:: 1.3 :param time: elapsed time, in milliseconds .. method:: get_clamp() -> bool Gets whether ``self`` should be clamped. .. method:: get_epsilon() -> float Gets the precision of the spring. .. method:: get_estimated_duration() -> int Gets the estimated duration of ``self``\, in milliseconds. Can be :obj:`~gi.repository.Adw.DURATION_INFINITE` if the spring damping is set to 0. .. method:: get_initial_velocity() -> float Gets the initial velocity of ``self``\. .. method:: get_spring_params() -> ~gi.repository.Adw.SpringParams Gets the physical parameters of the spring of ``self``\. .. method:: get_value_from() -> float Gets the value ``self`` will animate from. .. method:: get_value_to() -> float Gets the value ``self`` will animate to. .. method:: get_velocity() -> float Gets the current velocity of ``self``\. .. method:: set_clamp(clamp: bool) -> None 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 :obj:`~gi.repository.Adw.SpringAnimation.props.value_from` if a relative negative :obj:`~gi.repository.Adw.SpringAnimation.props.initial_velocity` is set. :param clamp: the new value .. method:: set_epsilon(epsilon: float) -> None 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. :param epsilon: the new value .. method:: set_initial_velocity(velocity: float) -> None Sets the initial velocity of ``self``\. Initial velocity affects only the animation curve, but not its duration. :param velocity: the initial velocity .. method:: set_spring_params(spring_params: ~gi.repository.Adw.SpringParams) -> None Sets the physical parameters of the spring of ``self``\. :param spring_params: the new spring parameters .. method:: set_value_from(value: float) -> None Sets the value ``self`` will animate from. The animation will start at this value and end at :obj:`~gi.repository.Adw.SpringAnimation.props.value_to`\. :param value: the value to animate from .. method:: set_value_to(value: float) -> None Sets the value ``self`` will animate to. The animation will start at :obj:`~gi.repository.Adw.SpringAnimation.props.value_from` and end at this value. :param value: the value to animate to Properties ---------- .. rst-class:: interim-class .. class:: SpringAnimation :no-index: .. attribute:: props.clamp :type: bool The type of the None singleton. .. attribute:: props.epsilon :type: float The type of the None singleton. .. attribute:: props.estimated_duration :type: int The type of the None singleton. .. attribute:: props.initial_velocity :type: float The type of the None singleton. .. attribute:: props.spring_params :type: ~gi.repository.Adw.SpringParams The type of the None singleton. .. attribute:: props.value_from :type: float The type of the None singleton. .. attribute:: props.value_to :type: float The type of the None singleton. .. attribute:: props.velocity :type: float The type of the None singleton.