@@ -433,6 +433,19 @@ def throttle(
433
433
return self
434
434
435
435
436
+ class DelayMod :
437
+ def delay (
438
+ self : Self ,
439
+ wait : int | float | str ,
440
+ ) -> Self :
441
+ """Delay the event listener.
442
+
443
+ :param wait: The delay time.
444
+ """
445
+ self ._mods ["delay" ] = [str (wait )]
446
+ return self
447
+
448
+
436
449
class ViewtransitionMod :
437
450
@property
438
451
def viewtransition (self : Self ) -> Self :
@@ -461,7 +474,7 @@ def self(self) -> Self:
461
474
return self
462
475
463
476
464
- class OnAttr (BaseAttr , TimingMod , ViewtransitionMod ):
477
+ class OnAttr (BaseAttr , TimingMod , DelayMod , ViewtransitionMod ):
465
478
_attr = "on"
466
479
467
480
@property
@@ -628,7 +641,7 @@ def focus(self) -> Self:
628
641
return self
629
642
630
643
631
- class OnIntersectAttr (BaseAttr , TimingMod , ViewtransitionMod ):
644
+ class OnIntersectAttr (BaseAttr , TimingMod , DelayMod , ViewtransitionMod ):
632
645
@property
633
646
def once (self ) -> Self :
634
647
"""Only trigger the event listener once."""
@@ -659,14 +672,9 @@ def duration(self, duration: int | float | str, *, leading: bool = False) -> Sel
659
672
return self
660
673
661
674
662
- class OnLoadAttr (BaseAttr , ViewtransitionMod ):
675
+ class OnLoadAttr (BaseAttr , ViewtransitionMod , DelayMod ):
663
676
_attr = "on-load"
664
677
665
- def delay (self , delay : int | float | str ) -> Self :
666
- """Delay the event listener."""
667
- self ._mods ["delay" ] = [str (delay )]
668
- return self
669
-
670
678
@property
671
679
def once (self ) -> Self :
672
680
"""Only trigger the event listener once."""
@@ -678,7 +686,7 @@ class OnRafAttr(BaseAttr, TimingMod):
678
686
_attr = "on-raf"
679
687
680
688
681
- class OnSignalPatchAttr (BaseAttr , TimingMod ):
689
+ class OnSignalPatchAttr (BaseAttr , TimingMod , DelayMod ):
682
690
_attr = "on-signal-patch"
683
691
684
692
def filter (self , include : str | None = None , exclude : str | None = None ) -> Self :
0 commit comments