Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

255
Vistas
how to implement click logic

hi everyone!

i have a map with dots MAP which every 3 seconds shows a block with info

a function that is already in progress, and I want the function to stop when clicking on a point and display an infoblock for me(and i did it).

sorry in advance below is my code

// map with dots
var isActive = 0;
var isLoading = 1;
const count = document.querySelectorAll("[data-id]");//circle svg around dot

function removeClass() {
 let infoCards = document.querySelectorAll("[data-info-id]");// info page name of the project
 infoCards.forEach((el) => {
  el.classList.remove("show");
 });
 }
 function removeCircle() {
  count.forEach((el) => {
   el.style.display = "none";
 });
}

function ready() {
 function setAround(percent, idx) {
  removeCircle();
  let beforeElemIdx = idx === 0 ? count.length - 1 : idx - 1;
  let beforeElem = document.querySelector(
   '[data-id="' + beforeElemIdx + '"]'
  );
  let elem = document.querySelector('[data-id="' + idx + '"]');
  elem.style.display = "block";
  elem.classList.remove('active-circle');

  beforeElem.style.display = "block";
  const math = 2 * Math.PI * elem.r.baseVal.value;
  elem.style.strokeDasharray = `${math} 1000`;
  let a = math * (1 - percent / 100);
  elem.style.strokeDashoffset = a;

  if (percent >= 99.5) {
    removeClass();
    let infoShow = document.querySelector(`[data-info-id="${idx}"]`);
    infoShow.classList.add("show");
    isLoading++;
    if (isLoading === count.length) {
      isLoading = 0;
    }
  }
}

requestAnimationFrame(draw);

function draw(t) {
  let idx = isLoading;
  requestAnimationFrame(draw);
  setAround((t / 30) % 100, idx);//timer 3sec
 }
}

document.addEventListener("DOMContentLoaded", ready);

and i did this

  var dots = document.querySelectorAll(".dota");
  var infoCards = document.querySelectorAll("[data-info-id]");
  let circle = document.querySelectorAll('[data-id]');

  dots.forEach((el) => {
    el.addEventListener('click', () => {
     let idx = el.dataset.dota;
     let circle = el.dataset.dota;
     showInfo(idx);
     addCircle(idx);
    });
  });

  function showInfo(idx) {
    removeClass();
     let elem = document.querySelector(`[data-info-id='${idx}']`);
      elem.classList.add('show');
  }

  function addCircle(idx) {
   let circle = document.querySelector(`[data-id='${idx}']`);
   circle.classList.add('active-circle');
  }

and if u want my site pls dm me i'll send my github page

PUG CODE

TY ALL!

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Have you tried making a condition into the drawing function that pauses it? If it's paused you can call another function that will draw the info of the specific dot only once and then create a condition in which it will resume the drawing normally.

When I used drawing function I've simply added a bool variable that stored if paused or not in the recursive function.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda