Dots in Carousel
1. Add Placeholder

2. Copy the JS code
3. Copy the CSS

Vertical dots
Last updated
Was this helpful?


Last updated
Was this helpful?
Was this helpful?
const carouselId = 'a16';
const dotsContainerId = 'b13';
var radDots = Radical.getAdByWindow(window);
if (!radDots.getMergedContent().inEditor) { radDots.onRender(onAdRenderDots); }
function onAdRenderDots() {
const carousel = radDots.getElementById(carouselId);
const dots = radDots.getElementById(dotsContainerId);
if (!carousel || !dots) {
return;
}
//add dynamic HTML structure for dots into the dots.domNone element based on the number of slides
const dotsHTML = carousel.getSlides().map((slide, index) => {
return `<div class="dot" style="border-radius: 50%;align-items: center;aspect-ratio: 1 / 1;height: 90%; cursor: pointer" data-index="${index}"></div>`;
}).join('');
//add container div for dots and set flexbox properties
dots.domNode.innerHTML = `<div class="dot-container" style="display: flex;justify-content: center;align-items: center;gap: 10px;width: 100%;height: 100%;">${dotsHTML}</div>`;
//set initial active dot
setActiveDot(carousel.getVisibleSlideIndex());
//add event listener for dots
dots.domNode.addEventListener('click', e => {
if (e.target.classList.contains('dot')) {
const index = parseInt(e.target.getAttribute('data-index'));
carousel.animateToSlideIndex(index);
setActiveDot(index);
}
});
carousel.slideChangeCallback((direction, visibleSlideIndex, domNode) => { setActiveDot(visibleSlideIndex); });
//pause carousel white mouse is over the dots
dots.domNode.addEventListener('mouseover', e => { carousel.pause();});
dots.domNode.addEventListener('mouseout', e => { carousel.resume(); });
}
function setActiveDot(index) {
//remove active class from all dots
document.querySelectorAll('.dot').forEach(d => d.classList.remove('active'));
//add active class to the dot
const dot = document.querySelectorAll(`.dot[data-index="${index}"]`);
dot.forEach(d => d.classList.add('active'));
}.dot {
border: 1px solid #6F13F2;
}
.dot.active {
background-color: #6F13F2;
}.dot {
border: 1px solid #6F13F2;
}
.dot.active {
background-color: #6F13F2;
}
.dot-container {
flex-direction: column;
}