generated from muhtadeetaron/nextjs-template
fix(ts): fix interfaces for type safety
This commit is contained in:
@ -3,6 +3,19 @@ import Link from "next/link";
|
||||
import Image from "next/image";
|
||||
import styles from "../css/SlidingGallery.module.css";
|
||||
|
||||
interface SlidingGalleryProps {
|
||||
views?: {
|
||||
id: string;
|
||||
content: React.ReactNode;
|
||||
}[];
|
||||
className?: string;
|
||||
showPagination?: boolean;
|
||||
autoScroll?: boolean;
|
||||
autoScrollInterval?: number;
|
||||
onSlideChange?: (currentIndex: number) => void;
|
||||
height?: string | number;
|
||||
}
|
||||
|
||||
const SlidingGallery = ({
|
||||
views = [],
|
||||
className = "",
|
||||
@ -11,7 +24,7 @@ const SlidingGallery = ({
|
||||
autoScrollInterval = 5000,
|
||||
onSlideChange = () => {},
|
||||
height = "100vh",
|
||||
}) => {
|
||||
}: SlidingGalleryProps) => {
|
||||
const [activeIdx, setActiveIdx] = useState(0);
|
||||
const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
|
||||
const scrollRef = useRef(null);
|
||||
@ -74,7 +87,7 @@ const SlidingGallery = ({
|
||||
}
|
||||
}, [dimensions]);
|
||||
|
||||
const handleScroll = (event) => {
|
||||
const handleScroll = (event: { target: { scrollLeft: any } }) => {
|
||||
handleUserInteraction();
|
||||
const scrollLeft = event.target.scrollLeft;
|
||||
const slideWidth = dimensions.width;
|
||||
|
||||
Reference in New Issue
Block a user