-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreenutil.js
35 lines (35 loc) · 1020 Bytes
/
screenutil.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
screenutil = {};
screenutil.getScreenCenter = function(coord){
if(coord === 'y' && coord === 'Y'){
return ( screenutil.getScrollOffset() + ( screenutil.getInnerHeight() / 2 ) );
}else if( coord ==='x' && coord === 'X'){
return ( document.body.clientWidth / 2 );
}else{
return {
'y': ( screenutil.getScrollOffset() + ( screenutil.getInnerHeight() / 2 ) ),
'x': ( document.body.clientWidth / 2 )
};
}
};
screenutil.getInnerHeight = function() {
var y;
if (self.innerHeight) {
y = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) {
y = document.documentElement.clientHeight;
} else if (document.body) {
y = document.body.clientHeight;
}
return y;
};
screenutil.getScrollOffset = function() {
var y;
if (self.pageYOffset) {
y = self.pageYOffset;
} else if (document.documentElement && document.documentElement.scrollTop) {
y = document.documentElement.scrollTop;
} else if (document.body) {
y = document.body.scrollTop;
}
return y;
};