fix: optimize toasts for mobile (#1392)
This commit is contained in:
@@ -55,14 +55,6 @@ export const ToastTimer: FunctionComponent<Props> = ({ toast, index }) => {
|
||||
resumeTimer()
|
||||
}, [resumeTimer])
|
||||
|
||||
const handlePageVisibility = useCallback(() => {
|
||||
if (document.visibilityState === 'hidden') {
|
||||
pauseTimer()
|
||||
} else {
|
||||
resumeTimer()
|
||||
}
|
||||
}, [pauseTimer, resumeTimer])
|
||||
|
||||
const handlePageFocus = useCallback(() => {
|
||||
resumeTimer()
|
||||
}, [resumeTimer])
|
||||
@@ -83,7 +75,6 @@ export const ToastTimer: FunctionComponent<Props> = ({ toast, index }) => {
|
||||
toastElement.addEventListener('mouseenter', handleMouseEnter)
|
||||
toastElement.addEventListener('mouseleave', handleMouseLeave)
|
||||
}
|
||||
document.addEventListener('visibilitychange', handlePageVisibility)
|
||||
window.addEventListener('focus', handlePageFocus)
|
||||
window.addEventListener('blur', handlePageBlur)
|
||||
|
||||
@@ -93,7 +84,6 @@ export const ToastTimer: FunctionComponent<Props> = ({ toast, index }) => {
|
||||
toastElement.removeEventListener('mouseenter', handleMouseEnter)
|
||||
toastElement.removeEventListener('mouseleave', handleMouseLeave)
|
||||
}
|
||||
document.removeEventListener('visibilitychange', handlePageVisibility)
|
||||
window.removeEventListener('focus', handlePageFocus)
|
||||
window.removeEventListener('blur', handlePageBlur)
|
||||
}
|
||||
@@ -105,7 +95,6 @@ export const ToastTimer: FunctionComponent<Props> = ({ toast, index }) => {
|
||||
handleMouseLeave,
|
||||
handlePageBlur,
|
||||
handlePageFocus,
|
||||
handlePageVisibility,
|
||||
resumeTimer,
|
||||
shouldAutoClose,
|
||||
toast.id,
|
||||
|
||||
Reference in New Issue
Block a user