mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Merge pull request #34936 from overleaf/jel-scroll-to-notification
[web] Scroll to new notification added above domains table GitOrigin-RevId: f62851398de3a54ef07c0e125c65a29dd84af6f8
This commit is contained in:
@@ -2,26 +2,7 @@ import Notification, {
|
||||
NotificationProps,
|
||||
} from '@/shared/components/notification'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
function elementIsInView(el: HTMLElement) {
|
||||
const scroll = window.scrollY
|
||||
const boundsTop = el.getBoundingClientRect().top + scroll
|
||||
|
||||
const viewport = {
|
||||
top: scroll,
|
||||
bottom: scroll + window.innerHeight,
|
||||
}
|
||||
|
||||
const bounds = {
|
||||
top: boundsTop,
|
||||
bottom: boundsTop + el.clientHeight,
|
||||
}
|
||||
|
||||
return (
|
||||
(bounds.bottom >= viewport.top && bounds.bottom <= viewport.bottom) ||
|
||||
(bounds.top <= viewport.bottom && bounds.top >= viewport.top)
|
||||
)
|
||||
}
|
||||
import { elementIsInView } from '@/shared/utils/element-in-view'
|
||||
|
||||
function NotificationScrolledTo({ ...props }: NotificationProps) {
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user