1
I wonder how I can make this script work one time, because I can’t do it:
// intenção de sair
function addEvent(obj, evt, fn) {
if (obj.addEventListener) {
obj.addEventListener(evt, fn, false);
}
else if (obj.attachEvent) {
obj.attachEvent("on" + evt, fn);
}
}
// gatilho
addEvent(document, 'mouseout', function(evt) {
if (evt.toElement == null && evt.relatedTarget == null ) {
$('#lightbox_overlay').slideDown();
};
});
// fechando o popup
$('#lightbox_overlay, #close').on('click', function(event) {
$('.lightbox').slideUp();
});
Put and did not work if($('#lightbox_overlay'). is(":Visible")) Return; addEvent(Document, 'mouseout', Function(evt) { if (evt.toElement == null && evt.relatedTarget == null ) { $('#lightbox_overlay'). slideDown(); } });
– Alberto B.
I tried that too and it didn’t work addEvent(Document, 'mouseout', Function(evt) { if($('#lightbox_overlay'). is(":Visible")) Return; { $('#lightbox_overlay'). slideDown(); }
– Alberto B.
You want the
obj.addEventListener(evt, fn, false);
roll only once?– Sam
that’s right, just once, when the mouse leaves, appear only once. I’ve tried using Jquery’s . one() but it didn’t roll.
– Alberto B.
Try trading the mouseout for mouseleave with the code I said.
– Sam
Check it out: https://jsfiddle.net/96z8dp3n/
– Sam
this is my : https://jsfiddle.net/albertobrasilbr/jxq7muat/1/
– Alberto B.