move homepage state changes to concurrent rendering for smoother scroll

This commit is contained in:
2026-04-16 20:19:04 +03:00
parent 323d42153a
commit 48cef31467
2 changed files with 8 additions and 8 deletions
+4 -4
View File
@@ -1,4 +1,4 @@
import { useEffect, useRef, useState } from 'react'
import { useEffect, useRef, useState, startTransition } from 'react'
import { motion, AnimatePresence } from 'framer-motion'
import { Play, Info, Flame, ChevronLeft, ChevronRight, Star, Clock, Tv2, Film } from '../../lib/icons'
import type { useNavigate } from 'react-router-dom'
@@ -74,15 +74,15 @@ export function FeaturedCarousel({
function goPrev() {
directionRef.current = -1
setIndex(i => (i - 1 + total) % total)
startTransition(() => setIndex(i => (i - 1 + total) % total))
}
function goNext() {
directionRef.current = 1
setIndex(i => (i + 1) % total)
startTransition(() => setIndex(i => (i + 1) % total))
}
function goTo(i: number) {
directionRef.current = i > index ? 1 : -1
setIndex(i)
startTransition(() => setIndex(i))
}
if (!item) return null