0

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

2
  • jQuery does not support background-color animation out-of-the-box... read here: api.jquery.com/animate Commented Aug 28, 2023 at 21:24
  • If you have a solution, please either add an answer below or close your question. Anyone else with the same issue won't know what your solution is. Commented Aug 29, 2023 at 9:32

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.