Created
October 22, 2014 20:54
-
-
Save gregkepler/13f7ac4c34ab7ca91bea to your computer and use it in GitHub Desktop.
Revisions
-
gregkepler created this gist
Oct 22, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ // originall from from http://cvmlrobotics.blogspot.com/2013/03/angularjs-get-element-offset-position.html function bounds( elm ) { try {return elm.offset();} catch(e) {} var rawDom = elm[0]; var _x = 0; var _y = 0; var body = document.documentElement || document.body; var scrollX = window.pageXOffset || body.scrollLeft; var scrollY = window.pageYOffset || body.scrollTop; _x = rawDom.getBoundingClientRect().left + scrollX; _y = rawDom.getBoundingClientRect().top + scrollY; var _width = rawDom.getBoundingClientRect().width; var _height = rawDom.getBoundingClientRect().height; return { left: _x, top:_y, width:_width, height:_height }; }