-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
42 lines (39 loc) · 1.22 KB
/
utils.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
36
37
38
39
40
41
42
function getScrollTop() {
let scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0
if (document.body) {
bodyScrollTop = document.body.scrollTop
}
if (document.documentElement) {
documentScrollTop = document.documentElement.scrollTop
}
scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop
return scrollTop
}
function getScrollHeight() {
let scrollHeight = 0, bodyScrollHeight = 0, documentScrollHeight = 0
if (document.body) {
bSH = document.body.scrollHeight
}
if (document.documentElement) {
dSH = document.documentElement.scrollHeight
}
scrollHeight = (bSH - dSH > 0) ? bSH : dSH
return scrollHeight
}
function getWindowHeight() {
let windowHeight = 0
if (document.compatMode == "CSS1Compat") {
windowHeight = document.documentElement.clientHeight
} else {
windowHeight = document.body.clientHeight
}
return windowHeight
}
function object2URL(obj) {
var str = []
for (var p in obj)
if (obj.hasOwnProperty(p)) {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]))
}
return str.join("&")
}