@amsterdam/design-system-react
Version:
All React components from the Amsterdam Design System. Use it to compose pages in your website or application.
11 lines (10 loc) • 374 B
JavaScript
export const setCurrentSlideIdToVisibleSlide = ({ observations, ref, setCurrentSlideId }) => {
const images = Array.from(ref.current?.children || []);
if (images.length === 0)
return;
observations.forEach((observation) => {
if (observation.isIntersecting) {
setCurrentSlideId(images.indexOf(observation.target));
}
});
};