I think I solved the problem using effect queues, this is the new
code:
function init()
{
var boxes = $('boxes');
boxes.select('.box').each(
function (box)
{
var tooltip = box.down('.tooltip');
Event.observe(box, 'mouseenter', mouseEnter.bindAsEventListener
(box, tooltip));
Event.observe(box, 'mouseleave', mouseLeave.bindAsEventListener
(box, tooltip));
}
);
function mouseEnter(event, tooltip)
{
if (!tooltip.visible())
{
tooltip.setStyle({
top: (this.positionedOffset().top + this.getHeight() - 20) + 'px',
left: (this.positionedOffset().left + parseInt(this.getWidth() /
2)) + 'px'
});
tooltip.appear({ duration: 0.2, to: 0.8, queue: { position: 'end',
scope: 'boxes-scope', limit: 1 }});
}
}
function mouseLeave(event, tooltip)
{
Effect.Queues.get('boxes-scope').invoke('cancel');
tooltip.hide();
}
}
document.observe('dom:loaded', function () { init(); });
Comments and suggestions are welcome!