kangax/fabric.js — pull request #1125 by GordoRank (2014-01-23 16:50:24+00:00)
Title: Speed up getPointer

```getPointer()``` is used in fabric actions very frequently.

In order to ensure the correct mouse coordinates when the canvas instance is potentially contained within a scrolled element, it performs a check every time it is called. This check involves looping through every parent DOM element.

This is unnecessary and means that Fabric is constantly looping through DOM elements over and over for almost every interaction.

We only really need to check for the scroll offset during mousemove.

Therefore this patch saves the scroll offset on ```mousemove``` by calling ```getScrollLeftTop()```

Then within ```getPointer()``` we simply retrieve those cached values if available.

During normal usage this is not usually too much of a problem. However with lots of objects on the canvas (I use 500+ objects with my turbo mode enabled) getPointer is called in excess of 5000 times when deselecting an object or group, causing a perceptible 1sec+ delay when clearing any selection with the mouse.

By only ever checking the scroll offset in ```mousemove``` this delay is reduced to 0.

NOTE : only two files are actually changed in this PR. I accidentally merged some changes into my master and had to revert them.