mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 00:02:31 +00:00
fix: cancel onboarding enter frames (#3418)
This commit is contained in:
@@ -82,7 +82,7 @@ export function OnboardingInlineCommandTerminal({
|
||||
|
||||
useEffect(() => {
|
||||
if (!autoScrollIntoView) {
|
||||
return
|
||||
return undefined
|
||||
}
|
||||
if (prefersReducedMotion) {
|
||||
const scrollFrame = window.requestAnimationFrame(() => {
|
||||
@@ -93,20 +93,32 @@ export function OnboardingInlineCommandTerminal({
|
||||
// Why: double rAF guarantees the browser commits the initial collapsed
|
||||
// styles before we flip to `entered`, so the height/opacity transition
|
||||
// actually plays instead of snapping straight to the final state.
|
||||
let enteredFrame: number | null = null
|
||||
const enterFrame = window.requestAnimationFrame(() => {
|
||||
window.requestAnimationFrame(() => setEntered(true))
|
||||
enteredFrame = window.requestAnimationFrame(() => setEntered(true))
|
||||
})
|
||||
return () => window.cancelAnimationFrame(enterFrame)
|
||||
return () => {
|
||||
window.cancelAnimationFrame(enterFrame)
|
||||
if (enteredFrame !== null) {
|
||||
window.cancelAnimationFrame(enteredFrame)
|
||||
}
|
||||
}
|
||||
}, [autoScrollIntoView, prefersReducedMotion])
|
||||
|
||||
useEffect(() => {
|
||||
if (autoScrollIntoView) {
|
||||
return
|
||||
return undefined
|
||||
}
|
||||
let enteredFrame: number | null = null
|
||||
const enterFrame = window.requestAnimationFrame(() => {
|
||||
window.requestAnimationFrame(() => setEntered(true))
|
||||
enteredFrame = window.requestAnimationFrame(() => setEntered(true))
|
||||
})
|
||||
return () => window.cancelAnimationFrame(enterFrame)
|
||||
return () => {
|
||||
window.cancelAnimationFrame(enterFrame)
|
||||
if (enteredFrame !== null) {
|
||||
window.cancelAnimationFrame(enteredFrame)
|
||||
}
|
||||
}
|
||||
}, [autoScrollIntoView])
|
||||
|
||||
// Why: tracking scroll *during* the height transition is unavoidably
|
||||
|
||||
Reference in New Issue
Block a user