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 18:29:14
 
 
À
21/03/2016 17:27:57
Information générale
Forum:
Javascript
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01633406
Message ID:
01633454
Vues:
38
>Michel, this is a Chrome-only solution but may be give you some hint for a different approach, if you think this path is worth exploring. On the mouse out event, hovered elements are checked with document.querySelectorAll(":hover"). I say Chrome-only because it's the only browser I saw honoring the real and current hovering. FF and IE/Edge remain on the previous element, the one that is "mouseoutting". Maybe there is a way to make it work in these other browsers, too...
>
>
><!DOCTYPE html>
><html>
> <head>
> <script type="text/javascript">
>function checkMouseInOtherDiv(out, otherDiv) {
>  out.innerHTML = "out";
>  // check to see if the other div is hovered
>  var oDiv = document.getElementById(otherDiv);
>  // go through the hover tree
>  var hoverTree = document.querySelectorAll(":hover");
>  var otherHovered = false;
>  for (var index = 0; index < hoverTree.length; index++) {
>    hover = hoverTree[index];
>    console.log("hover on " + hover.tagName + ": " + hover.id);
>    if (hover.id === otherDiv) {
>      // the mouse is over the other div, do something...
>      out.style.backgroundColor = "red";
>      otherHovered = true;
>      break;
>    }
>  }
>  console.log("is " + otherDiv + " hovered? " + otherHovered);
>}
> </script>
> </head>
> <body>
>  <div id="one" style="position: absolute; top: 0; left: 0; width: 100px; height: 100px; background-color: #ccc" onmouseout="checkMouseInOtherDiv(this, 'two')">
>  </div>
>  <div id="two" style="position: absolute; top: 100px; left: 0; width: 100px; height: 100px; background-color: #cc0" onmouseout="checkMouseInOtherDiv(this, 'one')">
>  </div>
> </body>
></html>
>
Thanks, this is a good approach. I checked that out yesterday but was unable to make something work.

While I investigated more on this, I realized that the parent frame sits on top of the toolbar frame. So, the toolbar frame will never be able to target for something sitting over. So, I adjusted the parent frame to create a ghost perimeter over the toolbar item that is responsible for launching and closing the menu. Then, as both div now are on the same layer, this all works.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform