gtramontina/draggable.js — pull request #10 by dotnetCarpenter (2014-01-07 21:21:33+00:00)
Title: Use getBoundingClientRect instead of offSet* and getComputedStyle

This PR uses [`getBoundingClientRect`](https://developer.mozilla.org/en-US/docs/Web/API/Element.getBoundingClientRect) to calculate position. `getBoundingClientRect` is AFAIK supported in all browsers except the original iPhone and BlackBerry5. This reduces the LOC of **draggable.js** by 5.

I've also done some performance optimizations by defining often used data structures, instead of recreating an anonymous object literal in each function invocation of *startDragging*, *getInitialPosition*, *repositionElement* and *removeDocumentListeners*. Namely **rectStruct** and **DraggableEvent**. Some JavaScript engines might optimize the use of anonymous objects but this approach gives a much more stable execution time. In my unscientific performance measures (re-re-re-reloading the test page) this PR is around 35% faster than the original.

All test pass in Opera 18.0, Safari 7.0.1 and Firefox 27 beta.

`getBoundingClientRect` has the added advantage of being able to report position of SVG elements, while offSet* can not. This PR is a part of my work to add SVG support to **draggable.js**.

Since this PR actually reduces the LOC of **draggable.js** by 5 lines and in the light of my work to support SVG, I would like to re-propose my former PR https://github.com/gtramontina/draggable.js/pull/6. At the moment I patch the bower version in each project. PR #6 make the overall code size of my projects smaller. Plus, PR #6 is 5 lines, so merging this PR and #6 will meet status quo in library size. :+1: