jquery 'animate' backgroundcolor'

30 Views Asked by At

I applied 'animate' to element 'card_id' on the next lines but it doesn't work, Can someone help and support me please?

window.navigate_item = function (id) {
  let item = data.find(i => i.ID == id);
  let card_id = `#card-${item.ID}`;
  // Simular click en boton categoria
  $(`#${item.CATEGORY_TAG}-left-nav-btn`).trigger('click');
  // Animación de card
  // Scroll a elemento
  setTimeout(() => {
    window.scrollTo({
      top: $(card_id).offset().top - 60,
      left: 0,
      behavior: "instant"
    })

    // Animación de cambio de fondo
    $(card_id).css('background-color', 'transparent'); // Establecer el fondo transparente inicialmente
    $(card_id).animate({
      backgroundColor: "rgba(255, 255, 0.5)"
    }, 1000); // Reducido el tiempo de animación a 1000 ms (1 segundo)
  }, 500);
};

I tried to apply 'animate' before and after '.offset' and into and out of 'setTimeout' but it doesn't work

0

There are 0 best solutions below