Witam, mam problem ponieważ skrypt tooltipa zle odliczna odleglosc od przedmiotu, przy pierwszym obrazku wyświetla się dobrze w drugim już sporo dalej od obrazka a w trzecim to już całkiem gdzie indziej.
<script type="text/javascript">
$(document).ready(function() {
$(".tip_trigger").hover(function(){
console.log('hover-on');
tip = $(this).find('.tip');
tip.show();
}, function() {
console.log('hover-off');
tip.hide();
}).mousemove(function(e) {
console.log('mousemove');
var mousex = e.clientX + 20;
var mousey = e.clientY + 20;
var tipWidth = tip.width();
var tipHeight = tip.height();
var tipVisX = $(window).width() - (mousex + tipWidth);
var tipVisY = $(window).height() - (mousey + tipHeight);
if ( tipVisX > 20 ) {
mousex = e.clientX - tipWidth - 70;
} if ( tipVisY > 20 ) {
mousey = e.clientY - tipHeight - 70;
}
tip.css({
top:mousey,
left:mousex
})
});
});
</script>