Skip to content

Commit 22d0fa4

Browse files
committed
Update data-on-intersect modifiers for RC.7
1 parent 685875c commit 22d0fa4

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/datastar_py/attributes.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import re
55
from collections.abc import Iterable, Iterator, Mapping
66
from itertools import chain
7-
from typing import TYPE_CHECKING, Literal, TypeAlias, Union
7+
from typing import TYPE_CHECKING, Literal, TypeAlias
88

99
if TYPE_CHECKING:
1010
from typing import Self
@@ -100,15 +100,9 @@
100100
]
101101

102102

103-
SignalValue: TypeAlias = Union[
104-
str,
105-
int,
106-
float,
107-
bool,
108-
dict[str, "SignalValue"],
109-
list["SignalValue"],
110-
None,
111-
]
103+
SignalValue: TypeAlias = (
104+
str | int | float | bool | dict[str, "SignalValue"] | list["SignalValue"] | None
105+
)
112106

113107

114108
class AttributeGenerator:
@@ -624,6 +618,17 @@ def full(self) -> Self:
624618
self._mods["full"] = []
625619
return self
626620

621+
@property
622+
def exit(self) -> Self:
623+
"""Trigger the event listener when the element exits the viewport."""
624+
self._mods["exit"] = []
625+
return self
626+
627+
def threshold(self, threshold: int) -> Self:
628+
"""Trigger the event listener when the element enters the viewport at the specified percentage."""
629+
self._mods["threshold"] = [str(threshold)]
630+
return self
631+
627632

628633
class OnIntervalAttr(BaseAttr, ViewtransitionMod):
629634
_attr = "on-interval"

0 commit comments

Comments
 (0)