So, I have a strange bug. if very fast move mouse around the page jquery replaces the wrong img src in the square blocks with preview.
this is js code:
$('.mini-info').bind('mouseenter', function() {
var xex = $(this).position().left;
var yey = $(this).position().top;
sim = $('img', this).attr('src');
kuda = $('a', this).attr('href');
$('#bcase div.'+$(this).attr('id')).addClass('active').css({
'top' : yey,
'left' : xex
}).attr({'onclick': 'location.href="'+kuda+'"'});
var omg = $('#bcase div.'+$(this).attr('id')+' div.b').length;
$('#bcase div.'+$(this).attr('id')+' div.b').css({
'width': wid/omg
});
});
$('#bcase > div').bind('mouseleave', function() {
$(this).removeClass('active');
$('.mini-info#'+$(this).attr('class')+' img').attr({'src': sim});
});
It’s possible to fix?
Normal work is when you move mouse upon one of the square block with preview, script will change image under the mouse. It’s work fine. But the bug above is not good…
In mouseleave event, you use
simvariable which is define in mouseenter event.Then with fast mouse mouvement, the mouseenter of an other div will be called before the mouseleave of previous event.
You have to change your arch. For example, when you create the new div in mouseenter, bind the mouseleave event at this point.
Something lke that (not tested):
see the jsfiddle : http://jsfiddle.net/bouillard/ptJQy/