Created
          February 25, 2017 14:59 
        
      - 
      
 - 
        
Save tmslnz/54ee17441854e3106ab3c8533cf6afd4 to your computer and use it in GitHub Desktop.  
    Get the absolute, untransformed offset of HTMLElement
  
        
  
    
      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 characters
    
  
  
    
  | function getAbsoluteOffset (el) { | |
| var _x = 0; | |
| var _y = 0; | |
| while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) { | |
| _x += el.offsetLeft; | |
| _y += el.offsetTop; | |
| el = el.offsetParent; | |
| } | |
| return { top: _y, left: _x }; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment