gmmoraesbr / flot

Automatically exported from code.google.com/p/flot
0 stars 0 forks source link

Margin/padding/border on body causes trouble for hover/click #360

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If flot is set on a div that is a direct descendant of the body, and the body 
has borders (setting the border property of css) then the hover and click 
events miss fire with respect to the points on the graph - the larger the width 
of the border the more distant the hover/click event is fired away from the 
point on the graph.

Here's an example of a page I'm working on:
http://dl.dropbox.com/u/380910/www/Polynom-test/polynoms.html

If you put the cursor directly on top of the graph, no hover or click events 
will fire, but if you put the cursor a bit to the left of the graph, it will 
recognize the event correctly.

You can see the correct behavior of the functionality in the following page, 
where I've went around the issue by adding an extra div for the whole page, and 
put the borders on the surrounding div instead.
http://dl.dropbox.com/u/380910/www/Polynom/polynoms.html

Original issue reported on code.google.com by TnidT...@gmail.com on 9 Jun 2010 at 10:57

GoogleCodeExporter commented 8 years ago
Nice page!

Well, either there's a bug in Flot in that it's using the wrong functions to 
calculate the position, or there's a bug in jQuery, or this is just doing 
something weird to the sizes. If you could figure out where the calculations go 
wrong in Flot, it would be most helpful.

Original comment by olau%iol...@gtempaccount.com on 13 Dec 2010 at 5:19

GoogleCodeExporter commented 8 years ago
This seems related to 301 which has a bit more analysis. Thanks for the report!

Original comment by olau%iol...@gtempaccount.com on 11 Mar 2011 at 4:51

GoogleCodeExporter commented 8 years ago
OK, I've looked into this, and the problem is that Flot is using .offset() to 
calculate the offset as that's what's provided by jQuery. Unfortunately, when 
you lookup this in the jQuery documentation, it explicitly states that it does 
not support "accounting for borders, margins, or padding set on the body 
element."

So without some other cross-browser method of finding the offset of the hover 
or click inside the placeholder, I guess the best work-around is to not set the 
border/padding/margin of body for the time being.

If anyone can figure out a better way to find the offset than what's currently 
done, that would be nice.

Original comment by olau%iol...@gtempaccount.com on 15 Mar 2011 at 5:09

GoogleCodeExporter commented 8 years ago

Original comment by olau%iol...@gtempaccount.com on 15 Mar 2011 at 5:10

GoogleCodeExporter commented 8 years ago

Original comment by dnsch...@gmail.com on 8 May 2012 at 12:33