Skip to content

Instantly share code, notes, and snippets.

@ki11ua
Created September 26, 2016 05:52
Show Gist options
  • Save ki11ua/d8182d081ec31d23a18e6c7ec6210ad9 to your computer and use it in GitHub Desktop.
Save ki11ua/d8182d081ec31d23a18e6c7ec6210ad9 to your computer and use it in GitHub Desktop.
current window height width state func
function isTouchDevice(){
return true == ('ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch);
}
function current() {
var state='click';
if(isTouchDevice()===true) {
state='touchstart';
}
return {h : Math.max(document.documentElement.clientHeight, window.innerHeight || 0), w: Math.max(document.documentElement.clientWidth, window.innerWidth || 0),scroll:(window.pageYOffset || document.documentElement.scrollTop) - (document.documentElement.clientTop || 0),state:state};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment