mirror of
https://github.com/cgzirim/seek-tune.git
synced 2025-12-18 17:34:22 +00:00
Add smooth scrolling to YouTube cards when circle is clicked
This commit is contained in:
parent
7c784d6384
commit
3ffa381e2d
1 changed files with 7 additions and 3 deletions
|
|
@ -6,10 +6,14 @@ const CarouselSliders = (props) => {
|
|||
const [activeVideoID, setActiveVideoID] = useState(null);
|
||||
const players = useRef({});
|
||||
|
||||
const activeVid = props.matches.length ? props.matches[0].YouTubeID : "";
|
||||
|
||||
useEffect(() => {
|
||||
setActiveVideoID(activeVid);
|
||||
if (props.matches.length > 0) {
|
||||
const firstVideoID = props.matches[0].YouTubeID;
|
||||
document
|
||||
.getElementById(`slide-${firstVideoID}`)
|
||||
.scrollIntoView({ behavior: "smooth" });
|
||||
setActiveVideoID(firstVideoID);
|
||||
}
|
||||
}, [props.matches]);
|
||||
|
||||
const onReady = (event, videoId) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue