File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"use client" ;
22
3- import { useState } from "react" ;
3+ import { useState , useEffect , useRef } from "react" ;
44import Link from "next/link" ;
55import {
66 Server ,
@@ -340,11 +340,21 @@ const demos = [
340340] ;
341341
342342function DemoGallery ( ) {
343+ const chatRef = useRef < HTMLDivElement > ( null ) ;
344+
345+ useEffect ( ( ) => {
346+ chatRef . current ?. scrollIntoView ( { inline : "center" , block : "nearest" } ) ;
347+ } , [ ] ) ;
348+
343349 return (
344350 < div className = "flex snap-x snap-mandatory gap-6 overflow-x-auto pb-4" >
345351 < div className = "w-[15%] shrink-0" aria-hidden = "true" />
346352 { demos . map ( ( demo ) => (
347- < div key = { demo . id } className = "w-[70%] shrink-0 snap-center" >
353+ < div
354+ key = { demo . id }
355+ ref = { demo . id === "chat" ? chatRef : undefined }
356+ className = "w-[70%] shrink-0 snap-center"
357+ >
348358 < h3 className = "mb-1 text-lg font-semibold" > { demo . title } </ h3 >
349359 < p className = "mb-3 text-sm text-fd-muted-foreground" > { demo . description } </ p >
350360 < div className = "overflow-hidden rounded-xl border border-fd-border shadow-lg" >
You can’t perform that action at this time.
0 commit comments