Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detecting new div before leaving the other one
Message
De
21/03/2016 05:58:18
 
 
À
21/03/2016 00:52:31
Information générale
Forum:
Javascript
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01633406
Message ID:
01633413
Vues:
49
Hi Michel,

You obviously can't change the order in which event fire, neither can you 'predict' in div1.mouseout() that div2.mouseover() will execute.

You might try a workaround where the div1.mouseout() handler execution is delayed for a couple of milliseconds and div2.mouseover() sets a flag; div1.mouseout() can check for this flag to decide what to do; the issue is how you make sure this flag is reset.

If you can make sure that no other elements sits between the 2 divs (eg. by overlapping), you can try to use event.relatedTarget in div2.mouseover():
jQuery('#div2').mouseover(function(ev){
  if (ev && ev.relatedTarget && ev.relatedTarget.id && ev.relatedTarget.id === 'div1') ev.relatedTarget.method();
  ...
});
>I have two div next to each other. When the second div is reached, I need to execute that code prior to the code that leaves the other div.
>
>So, I have onmouseover and onmouseout events. However, the onmouseout event of the first div always executes before the onmouseover of the next div.
>
>So, I need to find a way to structure that so the onmouseout of the first div will be smart enough to know it sits over the second div so I can cancel some code in the onmouseout of the first div in such circumstance.
Thierry Nivelet
FoxinCloud
Give your VFP application a second life, web-based, in YOUR cloud
http://foxincloud.com/
Never explain, never complain (Queen Elizabeth II)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform