🙋 Feature Request
Provide timer state (ex. isRunning) for toast.
🤔 Expected Behavior
A toast.timer provide state of current timer.
😯 Current Behavior
A toast.timer has private property timerId for check timer state.
💁 Possible Solution
Add property isRunning for Timer (or state="running | paused"):
|
class Timer { |
|
private timerId; |
|
private startTime: number; |
|
private remaining: number; |
|
private callback: () => void; |
🔦 Context
I create toasts with progress bar and when toast is hovered we can't stop animation because timer api doesn't have current state.
💻 Examples
function Snackbar<T>(props: ToastProps<T>) {
const { toast } = props;
// @ts-expect-error (timerId is private API)
const timerId = toast?.timer?.timerId;
return (
<div className={styles.root}>
<div
className={styles.progress}
style={{
animationDuration: `${toast.timeout}ms`,
animationPlayState: timerId === null ? "paused" : "running",
// Better solution:
// animationPlayState: toast.timer.isRunning ? "running" : "paused",
}}
/>
</div>
);
}
🧢 Your Company/Team
Yandex
🎁 Tracking Ticket (optional)
N/A
🙋 Feature Request
Provide timer state (ex. isRunning) for toast.
🤔 Expected Behavior
A
toast.timerprovide state of current timer.😯 Current Behavior
A
toast.timerhas private propertytimerIdfor check timer state.💁 Possible Solution
Add property
isRunningforTimer(orstate="running | paused"):react-spectrum/packages/@react-stately/toast/src/useToastState.ts
Lines 205 to 209 in a30e1bf
🔦 Context
I create toasts with progress bar and when toast is hovered we can't stop animation because timer api doesn't have current state.
💻 Examples
🧢 Your Company/Team
Yandex
🎁 Tracking Ticket (optional)
N/A