youcef92 / flotr

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

mouse track box does not close when mouse is moved outside of plot area - solution patch attached #110

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Go to playground, set mouse.track to true
2. Move mouse to the point that is nearest to the right border
3. Move mouse pointer to the right (outside of plot area)

What is the expected output? What do you see instead?
The track box should disappear, as it does when you move from vicinity of
the points. Instead it does not. 

What version of the product are you using? On what operating system?
R 147, prototype, Linux, Firefox.

----
Solution:
I have solved this by adding a new mousemove event handler on document. To
avoid double writing of the code my event handler calls hit() which appears
to work flawlessly. This is probably not the most efficient way to do it -
but it works and is safe to use.

Changes:
1) in init_events() add this line at the bottom:
    if (this.options.mouse.track)
        Event.observe($(document),'mousemove',
this.mouseMoveOnDocumentHandler.bindAsEventListener(this),false); 

2) add this function just after mouseMoveHandler():
    /**
     * Observes mouse movement over the whole document. Used for closing the
mouse track box when mouse is outside the plot area.
     * @param {Event} event - 'mousemove' Event object.
     */
    mouseMoveOnDocumentHandler: function(event){
        this.hit(this.getEventPosition(event));
    },

-----

This is it. I would appreciate if someone committed this to trunk... (or at
least suggested a better approach if there is one).

Thanks, enjoy!

Original issue reported on code.google.com by anz...@gmail.com on 21 Dec 2009 at 9:58

GoogleCodeExporter commented 8 years ago
I added this line to the initEvents function :

   .observe('mouseout', this.clearHit.bindAsEventListener(this))

This will clear the hit instead of observing an event on the document which may 
slow 
down the app.

Please tell me if it still works for you.

Original comment by fabien.menager on 27 Jan 2010 at 4:59

GoogleCodeExporter commented 8 years ago
Nope, that doesn't always work, but the combination of the two methods does:

.observe('mouseout', this.mouseMoveOnDocumentHandler.bindAsEventListener(this))

Not sure why clearHit() doesn't clear the hit... Interesting. :)

Original comment by anz...@gmail.com on 1 Feb 2010 at 8:14

GoogleCodeExporter commented 8 years ago
Can you show us under what circumstances exactly it does not clear?

I have a feeling it's caused by the "if(!this.prevHit) return;" line...

Original comment by peter....@solide-ict.nl on 21 Jul 2010 at 10:03

GoogleCodeExporter commented 8 years ago
How should this be updated for v168?
Thanks!

Original comment by mbbow...@gmail.com on 31 Jan 2011 at 7:44