use onTransitionEnded and remove setTimeout

This commit is contained in:
Abdalrzag Eisa 2025-06-14 22:24:09 +03:00
parent 524bcd90da
commit dad52d61ed
No known key found for this signature in database
GPG key ID: 4CD5A78B36195BC8

View file

@ -78,15 +78,15 @@ const SideDrawer = memo(forwardRef<HTMLDivElement, Props>(({ seriesInfo, classNa
const currentlyPlayingVideoRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const jumpToPlayingNow = () => {
const { current } = currentlyPlayingVideoRef;
if (current) {
setTimeout(() => { current.scrollIntoView({ behavior: 'smooth', block: 'center' }); }, 300);
current.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
}, []);
};
return (
<div ref={ref} className={classNames(styles['side-drawer'], className)} onMouseDown={onMouseDown}>
<div ref={ref} className={classNames(styles['side-drawer'], className)} onTransitionEnd={jumpToPlayingNow} onMouseDown={onMouseDown}>
<div className={styles['close-button']} onClick={closeSideDrawer}>
<Icon className={styles['icon']} name={'chevron-forward'} />
</div>