Tagged: ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1445639

    Hi Enfold team,
    I’m using the icon box grid with an image on the front and a shortcode for signing up to a Mailpoet newsletter on the back. It displays perfectly. How can I have it close ONLY if clicking out side of the icon box area, and not both in/out of the area?
    Thanks for your help.

    #1446070

    Hey Julie,
    Thank you for the link to your site, first I added the custom class click-to-close to your flipbox
    Enfold Support 5904
    Then I added this code to the end of your child theme functions.php file in Appearance ▸ Editor:

    function custom_click_to_close_flipbox_script() { ?>
      <script>
    jQuery(document).ready(function($) {
        $('.click-to-close .avia-icongrid-flipbox .av-icon-cell-item').hover(
            function() {
                var $flipback = $(this).find('.avia-icongrid-flipback');
                // Check if the transform is rotateY(0deg)
                if ($flipback.css('transform') == 'matrix(1, 0, 0, 1, 0, 0)') {
                    $(this).addClass('avia-hover');
                    console.log('avia-hover class added');
                }
            }
        );
    
        // Function to handle clicks outside the element
        $(document).on('click', function(event) {
            if (!$(event.target).closest('.click-to-close .avia-icongrid-flipbox .av-icon-cell-item').length) {
                $('.click-to-close .avia-icongrid-flipbox .av-icon-cell-item').removeClass('avia-hover');
                console.log('avia-hover class removed');
            }
        });
    
        // Prevent clicks inside the element from triggering the document click handler
        $('.click-to-close .avia-icongrid-flipbox .av-icon-cell-item').on('click', function(event) {
            event.stopPropagation();
        });
    });
    </script>
      <?php
    }
    add_action( 'wp_footer', 'custom_click_to_close_flipbox_script', 99 );

    Now when you hover over the flipbox and it flips the class avia-hover is added to it so that it won’t flip back, until you click outside of the element, in which the class is removed.
    please clear your browser cache and check.

    Best regards,
    Mike

    #1446364

    this is very nice !

    on mobile we have this behaviour (close on click outside) already – because of Content Setting : “Mobile Close Behaviour”
    does your script interfere with it?
    On mobile even a click on a different Flip-Card closes the other ones. ( that is my prefered behavior) and closes all on clicking outside.

    #1446387

    Hi,
    Thanks, it doesn’t seem to interfere with the mobile behavior.

    Best regards,
    Mike

    #1446423

    Thanks, Mike
    Everything works as expected. Looking good! Have a great weekend.

    #1446436

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Icon grid flip – close’ is closed to new replies.