I've put together an example to help explain the issue: http://codepen.io/tathianactn/pen/EaEzRB.
In this example I have a Map and various markers on the map (the blue squares). When you hover over the markers, a tooltip should appear with an image (left) and some text (right). The image & text div should always be the same height, therefore I am using javascript to determine the tallest div, and assigning that height value to the shorter div.
Initially the tooltip div is marked as "display: none;", then as you hover over a marker it "fadesin" and when you hover off the marker it "fadesout".
I have tested this code step by step, and all was working correctly until I added the fadein / fadeout actions. Before adding those two actions, the javascript re-sizing worked just fine (you can try removing those two lines to see), however when I added in those fade actions the heights stopped working correctly.
I noticed that if you quickly hover off and then hover back on the same marker, the height re-sizing does take effect.
Any ideas? I added the fadein after the re-sizing, supposing that all of the re-sizing would get done before the tooltip was exposed, but something is certainly not working correctly.
I would appreciate any help. Thanks!
$('a.map_marker').hover(function(e) {
//Change tooltip content based on location of marker clicked
var elementToGet = '.tooltip_html_source.'+$(this).attr('location');
var newHTML = $(elementToGet).html();
$('#tooltip_container .tooltip_content').html(newHTML);
//Get height of text div
var textHeight = $('#tooltip_container .tooltip_content .text').height();
//If text div is less than 70px (min height of image div)
if(textHeight < 70) {
//Then make the height of the text div = 70px
$('#tooltip_container .tooltip_content .text').height(70);
}
// else if the text div is greater than 70px
else if(textHeight > 70) {
//Make the height of the image div = the height of the text div
$('#tooltip_container .tooltip_content .image').height(textHeight);
}
//Once the resizing has been done, fade in the tooltip div
$('#tooltip_container').fadeIn('slow');
}, function() {
//On hover off, fade out the tooltip div
$('#tooltip_container').fadeOut('slow');
});