-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
38 lines (33 loc) · 932 Bytes
/
script.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
var ButtonPositioner = function(container, button) {
if (!button && !container) {
return;
}
var originalContainerPosition = button.style.position,
html = document.getElementsByTagName('html')[0],
originalContainerHeight = container.style.height;
var getHtmlHeight = function() {
var height = html.offsetHeight;
if (button.style.position == 'fixed') {
height - button.offsetHeight;
}
return height;
}
var setFixedPosition = function () {
button.style.position = 'fixed';
button.style.bottom = '0';
container.style.height = parseInt(container.offsetHeight)
+ button.offsetHeight + 'px';
};
var setOriginalPosition = function () {
button.style.position = originalContainerPosition;
button.style.height = originalContainerHeight;
};
var rerender = function() {
if (getHtmlHeight() >= window.innerHeight) {
setFixedPosition();
} else {
setOriginalPosition();
}
}
rerender();
};