Manual Control
Manual control navigation items Controller
If you want to automatically jump to the specified page slideToPage when retrieving API data, please set the isUseAnimation parameter with false
import AcroolCarousel, {Controller, ICarouselState} from '@acrool/react-carousel';
import {useState} from 'react';
const SyncCarousel = () => {
const [controller, setController] = useState<Controller>();
const [carouselState, setCarouselState] = useState<ICarouselState>();
useEffect(() => {
handleSlide(4, false);
}, [controller]);
const handleSlide = (page: number, isUseAnimation = true) => {
controller?.slideToPage(page, isUseAnimation);
}
return <div>
<AcroolCarousel
// ...ignore some
onSlideChange={setCarouselState}
setController={setController}
/>
currentPage: {carouselState?.page.total}
</div>
}
Try click button