Skip to content

Commit

Permalink
Enable animating offset with string. Textualize#3028
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvalmo committed Aug 3, 2023
1 parent 4248b44 commit 1f203c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/textual/css/scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,16 @@ def resolve(self, size: Size, viewport: Size) -> Offset:
round(y.resolve(size, viewport)),
)

@classmethod
def parse(cls, token: str) -> ScalarOffset:
x, y = token.split()
# fmt: off
return cls(
Scalar.parse(x, Unit.WIDTH),
Scalar.parse(y, Unit.HEIGHT)
)
# fmt: on


NULL_SCALAR = ScalarOffset(Scalar.from_number(0), Scalar.from_number(0))

Expand Down
2 changes: 2 additions & 0 deletions tests/test_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ async def test_animate_height() -> None:
Offset(10, 5),
(10, 5),
(10.0, 5.0),
"10 5",
"10.0 5.0",
]


Expand Down

0 comments on commit 1f203c1

Please sign in to comment.