I have the following code:
jQuery(function () {
jQuery('.tooltip').tooltip({
position: {
my: "left top",
at: "right top",
collision: "flip fit"
},
content: function () {
var element = jQuery(this);
if (element.is("[rel]")) {
var text = element.attr("rel");
return '<div><img class="map" src="' + text + '"></div>';
}
if (element.is("[title]")) {
return element.attr("title");
}
if (element.is("img")) {
return element.attr("alt");
}
}
});
});
This works as expected but only after the initial hover (hover over "rel" element).
On the first mouse hover the tooltip appears but collides with the window (the image is not flipped or re-sized). Starting from the 2nd hover, the tooltip is flipped and re-sized as needed.
I've inspected the "tooltip" elements both before the 1st hover and after it, but I haven't found any differences. I've also checked the CSS for each element with the same no-result.
Any ideas would help, thanks.
EDIT:
live site here : http://castle.staging.wpengine.com/themes/
if you check the website make sure the image is in collision with the browser(you may have to resize your browser if you have a huge screen)
Some images to point out the issue: