End Position Not Correct When Dragging Splitbar
I noticed an issue while testing a fix for #52. The code doesn't seem to get (or maybe just doesn't correctly process) the last mouse event when dragging a splitbar.
To reproduce, look at the following Plunker:
http://plnkr.co/ijRt6M2ob5wZNG0bbxrj
Drag one of the splitbars quickly, and then stop moving, but don't release the mouse button. The position of the mouse and position of the splitbar will often be different. Then slightly move the mouse either up/down or left/right. The splitbar will jump to the current mouse location.
I'm pretty sure this issue would be solved by caching the data/events to only calculate once ~60 frames during the animation. That was in our initial release but I had issues migrating it to 1.x and abandoned it as non-essential at the time.
This should probably be the next thing knocked out so the component is more efficient. Check out the cache_layout_values() function in v<=0.x.x for reference if you feel like taking a crack at it. Otherwise, I'll work on it this weekend if time permits.
I am noticing though that the bar snaps to position when I release the mouse. Perhaps, that's due to slight movement though.
I suppose we could always move the code to calculate lastPos into a function and call it on release too so we are sure to get the last mouse position.
No solution or root cause yet, but here are a few additional notes from my investigation today:
• The mousemove handler is being called for all mouse moves immediately as expected
• The draw function is being called right after that as expected
These things both happen immediately as the mouse is moved.
However, I see two slightly different behaviors with regard to mouse up:
• In this Plunker, if you release the mouse button, then the final repaint occurs (as you also saw). Note that there is no "slight movement" that is triggering the repaint. No additional mouse message is received, nor is any call to draw made when the mouse button is released. It's like it's finally getting around to drawing the frame that was previously supposed to have been drawn.
• In my actual app, if you continue to hold the mouse button for about 1 second after you stop dragging, then the splitbar updates to the correct position too (this doesn't occur in the Plunker). It does update to the correct position if you release the mouse button before that 1 second is up though.
Not sure what causes the difference, but I expect it's just something in Angular triggering an update that causes a screen repaint before the mouse release if you hold the button down longer.
The main issue is just that the repaint that occurs on mouse up is just getting around to showing something that the draw function drew a while ago.