Last active
March 14, 2017 17:52
-
-
Save lonelydatum/7fd01fff3955922901c06cffdb4b0ce2 to your computer and use it in GitHub Desktop.
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
getOffset(obj) { | |
var offsetLeft = 0; | |
var offsetTop = 0; | |
do { | |
if (!isNaN(obj.offsetLeft)) { | |
offsetLeft += obj.offsetLeft; | |
} | |
if (!isNaN(obj.offsetTop)) { | |
offsetTop += obj.offsetTop; | |
} | |
} while(obj = obj.offsetParent ); | |
return {left: offsetLeft, top: offsetTop}; | |
} | |
//source: https://mobiforge.com/design-development/html5-mobile-web-touch-events |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment