Showing posts with label mouse. Show all posts
Showing posts with label mouse. Show all posts

Wednesday, June 29, 2016

Popup window dancing issue

In my application, there was once an issue where in after continuous movement of mouse over a popup window, the mouse down and mouse up event is not triggered.

In such a case, even if the mouse has not been clicked, on mouse movement, the pop up window also moves along with it. This is the dancing popup issue. :) . This term has been coined by me. 

So what should you do in such a case?
This is what I did:
  1. Check for the button of the mouse clicked
  2. Check for the event: 
     window.event.button  
    
  3. If the left button is clicked, then the value = 1
  4. If right button is clicked, then the value = 3
Now this worked for me, only in IE 9 and below.

For chrome I checked the below value to be equal to 1:

 event.buttons  

Only if these values equaled 1, then the popup window was moved, i.e. the x and y coordinates along with top and left values were changed.

So together, we can frame the check in the following way:


 var mouseClickValue = (Util.isIE() ? window.event.button : evt.buttons);  
 if (mouseClickValue) {  
   // move the pop up window  
 }  

I will add the fix required for IE 11 and above, very soon. 
Watch this blog for more :)

Hope this fix helps!! Happy coding!!