+ {/* Keep the inlined first frame visible during the animation request. */}

-
- {!motionFailed && (
-
- )}
+ {(permitsMotion || motionReady) && (
{
- // A failed request can finish before hydration attaches onError.
- if (
- image?.complete &&
- !image.naturalWidth &&
- image.currentSrc.endsWith(motion)
- ) {
- setMotionFailed(true)
- }
- }}
- onError={() => setMotionFailed(true)}
- className="block h-auto w-full"
+ hidden={!showMotion}
+ onLoad={() => setMotionReady(true)}
+ className="h-auto w-full"
/>
-
+ )}