Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/textual/_animator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from textual import _time
from textual._callback import invoke
from textual._compat import cached_property
from textual._easing import DEFAULT_EASING, EASING
from textual._easing import DEFAULT_EASING, EASING, DefaultEasingFunctions
from textual._types import AnimationLevel, CallbackType
from textual.timer import Timer

Expand Down Expand Up @@ -303,7 +303,7 @@ def animate(
final_value: object = ...,
duration: float | None = None,
speed: float | None = None,
easing: EasingFunction | str = DEFAULT_EASING,
easing: EasingFunction | DefaultEasingFunctions = DEFAULT_EASING,
delay: float = 0.0,
on_complete: CallbackType | None = None,
level: AnimationLevel = "full",
Expand Down
37 changes: 37 additions & 0 deletions src/textual/_easing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

from math import cos, pi, sin, sqrt
from typing import Literal


def _in_out_expo(x: float) -> float:
Expand Down Expand Up @@ -129,3 +130,39 @@ def _in_out_bounce(x: float) -> float:

DEFAULT_EASING = "in_out_cubic"
DEFAULT_SCROLL_EASING = "out_cubic"

DefaultEasingFunctions = Literal[
"none",
"round",
"linear",
"in_sine",
"in_out_sine",
"out_sine",
"in_quad",
"in_out_quad",
"out_quad",
"in_cubic",
"in_out_cubic",
"out_cubic",
"in_quart",
"in_out_quart",
"out_quart",
"in_quint",
"in_out_quint",
"out_quint",
"in_expo",
"in_out_expo",
"out_expo",
"in_circ",
"in_out_circ",
"out_circ",
"in_back",
"in_out_back",
"out_back",
"in_elastic",
"in_out_elastic",
"out_elastic",
"in_bounce",
"in_out_bounce",
"out_bounce",
]
3 changes: 2 additions & 1 deletion src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
from textual._context import active_app, active_message_pump
from textual._context import message_hook as message_hook_context_var
from textual._dispatch_key import dispatch_key
from textual._easing import DefaultEasingFunctions
from textual._event_broker import NoHandler, extract_handler_actions
from textual._files import generate_datetime_filename
from textual._path import (
Expand Down Expand Up @@ -1064,7 +1065,7 @@ def animate(
duration: float | None = None,
speed: float | None = None,
delay: float = 0.0,
easing: EasingFunction | str = DEFAULT_EASING,
easing: EasingFunction | DefaultEasingFunctions = DEFAULT_EASING,
on_complete: CallbackType | None = None,
level: AnimationLevel = "full",
) -> None:
Expand Down
3 changes: 2 additions & 1 deletion src/textual/css/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing_extensions import TypedDict

from textual._animator import DEFAULT_EASING, Animatable, BoundAnimator, EasingFunction
from textual._easing import DefaultEasingFunctions
from textual._types import AnimationLevel, CallbackType
from textual.color import Color
from textual.css._style_properties import (
Expand Down Expand Up @@ -1382,7 +1383,7 @@ def animate(
duration: float | None = None,
speed: float | None = None,
delay: float = 0.0,
easing: EasingFunction | str = DEFAULT_EASING,
easing: EasingFunction | DefaultEasingFunctions = DEFAULT_EASING,
on_complete: CallbackType | None = None,
level: AnimationLevel = "full",
) -> None:
Expand Down
4 changes: 2 additions & 2 deletions src/textual/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from textual._context import NoActiveAppError
from textual._debug import get_caller_file_and_line
from textual._dispatch_key import dispatch_key
from textual._easing import DEFAULT_SCROLL_EASING
from textual._easing import DEFAULT_SCROLL_EASING, DefaultEasingFunctions
from textual._extrema import Extrema
from textual._styles_cache import StylesCache
from textual._types import AnimationLevel
Expand Down Expand Up @@ -2463,7 +2463,7 @@ def animate(
duration: float | None = None,
speed: float | None = None,
delay: float = 0.0,
easing: EasingFunction | str = DEFAULT_EASING,
easing: EasingFunction | DefaultEasingFunctions = DEFAULT_EASING,
on_complete: CallbackType | None = None,
level: AnimationLevel = "full",
) -> None:
Expand Down
Loading