All-in-One Reviews custom_js to catch slider event

  • Issue description: I am using the All-In-One Reviews Widget and I’m trying to do some javascript action on widget loaded and everytime it update → slide. Is there an event name i can listen ? My custom_js is down below.

Thanks for any help

const waitForElement = (selector, root = document) => new Promise(res => {
  const observer = new MutationObserver(() => {
    const element = root.querySelector(selector);
    if (element) {
      res(element);
      observer.disconnect();
    }
  });

  observer.observe(root, {
    childList: true,
    subtree: true
  });
});

const elfsight_app_id = "my elfsight_app_id ";

waitForElement('.elfsight-app-'+elfsight_app_id).then(() => {  
{  
  console.log("loaded");  
  document.addEventListener('slide', (e) => {
    console.log("slide", e.currentTarget);    
  });  
});

Hi there and welcome to the Community, @user26166 :waving_hand:

Here is a script snippet from our devs:

widget.on('init', () => {
  // Code that will be executed when the widget loads

  const swiper = util.findElement('.swiper')?.swiper;
  if (!swiper) return;

  swiper.on('slideChange', () => {
    // Code that will be executed when the slide changes
  });
});

Feel free to adjust it to your specific case and add it to the Custom JS field on the Settings tab of your widget’s settings.

Try it out and let me know if it helped :slightly_smiling_face:

Thank you so much, that’s what i was looking for.

I just use the method “slideChangeTransitionEnd” instead of “slideChange”

It’s my pleasure :wink:

In the meantime, we’d like to invite you to join our Giveaway, where you could win 4 FREE Months for your subscription.

Check the details and join in: May Giveaway: Celebrate Community Anniversary & Win 4 FREE MONTHS! :wrapped_gift: