Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1474513

    Hey there,

    We love the Icon Circle element for the site we’re making now, but nearly nobody hover over the icon circle and therefore doesn’t view the content of each circle.

    Is there a way to set an timed autodisplay of the Icon circles content automatically, while scrolling the page?

    Here’s a screenshot of the page I mean:

    Icon Circle

    Ideally, this would be the behaviour:

    1. logo shows in the center, then after 2-3 seconds
    2. First dot on top animates and shows up content in the center, then 2 seconds later,
    3. Second dot on the right animates and shows up content in the center, then 2 seconds later,
    4. Third and last dot on the left animates and show up content in the center.

    Maybe also on loop, so it continues.

    Is it possible?

    Thank you for your help.

    Antonio

    #1474515

    you can see here a trial:
    https://guenterweber.com/

    if you hover the circle the animation stops (mouseenter) if you leave the circle – animation starts again.
    Why there is a small delay – between icon and icon-text – i do not know

    put this to your child-theme functions.php

    function rotation_of_active_circle_icons(){
    ?>
    <script type="text/javascript">
    window.addEventListener("DOMContentLoaded", function () { 
    
      // Select the parent element
      const parentElement = document.querySelector('.avia-icon-circles-inner'); // Parent
    
      // The classes to target and toggle
      const targetClasses = ['avia-icon-circles-icon', 'avia-icon-circles-icon-text']; // children
      const activeClass = 'active';
    
      // Function to rotate the active class among children with specific classes
      function rotateActiveClassPair(parent, targetClasses, activeClass, interval) {
          // Get children for each target class
          const childrenGroups = targetClasses.map(cls => Array.from(parent.querySelectorAll(<code>.${cls}</code>)));
          const maxLength = Math.max(...childrenGroups.map(group => group.length));
          let currentIndex = 0;
          let rotationInterval;
    
          // Ensure there are children to rotate
          if (maxLength === 0) return;
    
          // Function to remove all active classes
          function removeAllActiveClasses() {
              childrenGroups.flat().forEach(child => child.classList.remove(activeClass));
          }
    
          // Start the rotation
          function startRotation() {
              rotationInterval = setInterval(() => {
                  // Remove the active class from the current pair
                  childrenGroups.forEach(group => {
                      if (group[currentIndex]) {
                          group[currentIndex].classList.remove(activeClass);
                      }
                  });
    
                  // Move to the next index (loop back to the start if at the end)
                  currentIndex = (currentIndex + 1) % maxLength;
    
                  // Add the active class to the new pair
                  childrenGroups.forEach(group => {
                      if (group[currentIndex]) {
                          group[currentIndex].classList.add(activeClass);
                      }
                  });
              }, interval);
          }
    
          // Start rotating initially
          startRotation();
    
          // Pause the rotation and remove all active classes on hover
          parent.addEventListener('mouseenter', () => {
              clearInterval(rotationInterval); // Stop the rotation
              removeAllActiveClasses(); // Remove all active classes
          });
    
          // Resume the rotation when the mouse leaves the parent
          parent.addEventListener('mouseleave', () => {
              startRotation(); // Restart the rotation
          });
      }
    
      // Start rotating the active class every 3 seconds
      rotateActiveClassPair(parentElement, ['avia-icon-circles-icon', 'avia-icon-circles-icon-text'], 'active', 3000);
    
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'rotation_of_active_circle_icons');
    #1474560

    PS: that delay comes from the default transition timing:

    .avia-icon-circles-icon-text {
      transition:all .8s cubic-bezier(.175,.885,.32,1.275);
    }

    it you set it to none – there will be no delay – see example page. But then not center image is shown.

    #top .avia-icon-circles-icon-text {
      transition: none;
    }
    #1474565

    Thank you for the reply @Guenni007 and for the sample website you gave me.

    Unfortunately, that doesn’t seem to do what I mean, as the animation goes normally also on our site when you start scrolling the page; for the site you sent me, you still have to hover over the icons to display their content inside the center of the circle.

    What I would like to do is for everything to show without having to hover over the icon, i.e. you start seeing the logo inside the circle, then after 2 seconds you see the content of the first icon displayed, then after 2 seconds you see the content of the second icon displayed and lastly, after another 2 seconds you see the content of the third icon displayed in the center.
    So everything would display automatically, as nearly nobody would point the mouse to the icons to reveal content, since nobody knows and the vast majority don0t event imagine there is something else to view.

    Hope that makes sense and hope that is something feasible, or if not, maybe that is a new feature to add to the next version of Enfold.

    Thanks

    #1474566

    that example page : on hover the normal behaviour is working on mouseleave the animation starts. every 3sec the active state is changing.
    ???

    the default behaviour is important for me – because i do have links on each icon. So if the animation still is working that hampers the default action.

    #1474567

    here is the result for that script and your “home” page:
    https://webers-testseite.de/circle-rotator.mp4

    or with a background-image on your text:

    
    #top .avia-icon-circles-icon-text {
      background-image: url(https://coachcristina.com/wp-content/uploads/2024/12/WhatsApp-Image-2024-12-11-at-11.09.04.jpeg) !important;
      background-repeat: no-repeat !important;
      background-position: center center !important;
      transition: all 1s cubic-bezier(.175,.885,.32,1.275);
    }
    
    #top .avia-icon-circles-icon-text-inner * {
      color: #FFF
    }
    #1474579

    Hi,

    Thanks for helping out @guenni007. Did that answer your question @abortolotti?

    Best regards,
    Rikard

    #1474586

    Thank you for the explanation @guenni007, I really appreciate. Thank you for asking @Rikard.
    There is however something that either I do not quite understand or is not working as expected on my computer (Mac on Safari):

    If I go to your sample website, I never see any auto animation of the Icon Circles; I need to go there with my mouse, hover on one icon and I see the content, then nothing happens for the other icons; if I leave with the mouse the Circle, nothing happens, no animation starts.
    I recorded the screen of my computer to show you what I mean:
    Webertrial

    The video you sent me of my homepage (https://webers-testseite.de/circle-rotator.mp4) works well, but I added the code you wrote in my Quick CSS and nothing happens. The only thing I get is that when I now hover over an icon, the content in the middle has a transparent background (which is actually great) and not the white background it had before. The transparent background is great now, but I can’t get any animation to work automatically, nor if I hover over an icon, then leave nothing happens; there is no effect like in the video you sent me of my homepage trial.
    Here you see a screen recording of what I mean:
    CristinaHome

    So I’m not sure what I’m doing wrong.

    Also, I do not have a child-them installed, I only use the main Enfold theme. Therefore, I haven’t put any code in the function.php file.

    #1474591

    yes – you are right. I did not check the other browsers ( on firefox it works the way i intendet to do so ). Sorry. But i do not see in the code any browser-specific selectors or commands.
    i have to check this. …

    #1474593

    i hope – if Günter or Ismael knows a much easier way to obtain that. ;)

    i think that the above mentioned transition to show the text disturbs a bit the whole timing.
    but try with a bit more delay

    #top .avia-icon-circles-icon-text {
      transition: all 1s cubic-bezier(.175,.885,.32,1.275);
    }

    for child-theme functions.php:

    function rotation_of_active_circle_icons(){
    ?>
    <script type="text/javascript">
    document.addEventListener("DOMContentLoaded", () => {
        const parent = document.querySelector('.avia-icon-circles-inner');
        const icons = parent.querySelectorAll('.avia-icon-circles-inner .avia-icon-circles-icon');
        const texts = parent.querySelectorAll('.avia-icon-circles-inner .avia-icon-circles-icon-text');
        let currentIndex = 0;
        let intervalId;
    
        function updateActiveClass() {
            // Remove the 'active' class from all elements
            icons.forEach(icon => icon.classList.remove('active'));
            texts.forEach(text => text.classList.remove('active'));
    
            // Add the 'active' class to the current index
            setTimeout(() => {
    			icons[currentIndex].classList.add('active');
    			texts[currentIndex].classList.add('active');
    		}, 1500);
    
            // Update the index to the next element (loop back to 0 if at the end)
            currentIndex = (currentIndex + 1) % icons.length;
        }
    
        function startIntervalWithDelay() {
            // Add a delay before starting the interval
            setTimeout(() => {
                updateActiveClass(); // Ensure the first activation happens after the delay
                intervalId = setInterval(updateActiveClass, 6000);
            }, 3000); // 3-second delay before starting the interval
        }
    
        function stopInterval() {
            clearInterval(intervalId);
        }
    
        // Start the interval with delay
        startIntervalWithDelay();
    
        // Pause on hover and resume on mouse leave
        parent.addEventListener('mouseenter', stopInterval);
        parent.addEventListener('mouseleave', startIntervalWithDelay);
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'rotation_of_active_circle_icons');
    #1474615

    the last codesnippet works on all browsers. sadly on safari and chrome the avia-icon-circles-main-logo is only showing for a small moment.
    On Firefox it works a bit nicer. i could not find a solution yet for that …

    It doesn’t seem to work completely. After a few cycles it gets a little out of hand. It’s difficult (for me) because the main logo ( avia-icon-circles-main-logo ) is not part of the elements within avia-icon-circles-inner

    … I’m sticking to one solution – because it might be a nice option to have.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.