Created
March 5, 2020 11:03
-
-
Save sungraiz/add5c6dc6b0cb57e5d1f24483a359e59 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Child Theme - Custom JS File for Users to add their own JS code */ | |
| (function($){ | |
| function equalHeights(){ | |
| // Select and loop the container element of the elements you want to equalise | |
| $(document).find('.rh_latest-properties.rhea_properties_default').each(function(){ | |
| // Cache the highest | |
| var highestBox = 0; | |
| // Select and loop the elements you want to equalise | |
| $('.rh_prop_card__details_elementor', this).each(function(){ | |
| // If this box is higher than the cached highest then store it | |
| if($(this).height() > highestBox) { | |
| highestBox = $(this).height(); | |
| } | |
| }); | |
| // Set the height of all those children to whichever was highest | |
| $('.rh_prop_card__details_elementor',this).height(highestBox); | |
| }); | |
| } | |
| window.addEventListener('DOMContentLoaded', function(){ | |
| if($('.rh_latest-properties.rhea_properties_default').length > 0){ | |
| equalHeights(); | |
| let ids = $('.rh_latest-properties.rhea_properties_default').map(function() { | |
| return $(this).attr('id'); | |
| }); | |
| // Select the node that will be observed for mutations | |
| const targetNode = document.getElementById(ids[0]); | |
| // Options for the observer (which mutations to observe) | |
| const config = { attributes: true, childList: true, subtree: true }; | |
| // Create an observer instance linked to the callback function | |
| const observer = new MutationObserver(equalHeights); | |
| // Start observing the target node for configured mutations | |
| observer.observe(targetNode, config); | |
| } | |
| }); | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment