forked from shinovon/mpgram-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatscroll.orig.js
34 lines (34 loc) · 869 Bytes
/
chatscroll.orig.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
function getScrollY(){
var a = window.pageXOffset !== undefined;
var b = ((document.compatMode || "") === "CSS1Compat");
return a ? window.pageYOffset : b ? document.documentElement.scrollTop : document.body.scrollTop;
}
function getHeight(){
var a = window.innerHeight !== undefined;
return a ? window.innerHeight : document.documentElement.clientHeight || document.body.clientHeight;
}
function autoScroll(force,dir){
try{
text=document.getElementById("text");
bottom=document.getElementById("bottom");
dir=dir?!reverse:reverse;
if(force){
if(dir)
bottom.scrollIntoView();
else
text.scrollIntoView();
}else{
try{
tw=text.clientHeight;
sh=getHeight();
sy=getScrollY();
ph=document.body.scrollHeight;
if(sy>ph-tw-sy){
text.scrollIntoView();
}
}catch(e){
text.scrollIntoView();
}
}
}catch(e){}
}