-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.js
More file actions
50 lines (44 loc) · 1.51 KB
/
2.js
File metadata and controls
50 lines (44 loc) · 1.51 KB
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
43
44
45
46
47
48
49
var bl,cursor,observer;
var targetNode = document.getElementById('bl');
// Options for the observer (which mutations to observe)
var config = { attributes: true, childList: true, subtree: true };
var callback = function(mutationsList, observer) {
for(var mutation of mutationsList) {
if (mutation.type == 'childList') {
console.log('A child node has been added or removed.');
}
else if (mutation.type == 'attributes') {
//console.log('The ' + mutation.attributeName + ' attribute was modified.');
}
}
flow();
observer.disconnect();
};
observer = new MutationObserver(callback);
function flow()
{
//console.log("laoded");
bl=document.getElementById("bl");
if(bl.style.marginLeft!==""||bl.style.marginRight!=="")
{
//console.log(bl.style.marginLeft+","+bl.style.marginRight);
observer.observe(targetNode, config);
//console.log("ow");
bl.style.marginLeft="";
bl.style.marginRight="";
return;
}
cursor=document.getElementById("cursor");
var nl=bl.offsetHeight/cursor.offsetHeight;
bl.style.marginLeft=Math.floor((bl.offsetWidth+bl.offsetLeft-cursor.offsetLeft)/(bl.offsetHeight/cursor.offsetHeight)+1).toString()+"px";
while(bl.offsetHeight/cursor.offsetHeight>nl)
{
//console.log("t");
bl.style.marginLeft=(parseInt(bl.style.marginLeft)-1).toString()+"px";
}
var ml=parseInt(bl.style.marginLeft);
var m2l=Math.floor(ml/2);
bl.style.marginLeft=(m2l).toString()+"px";
bl.style.marginRight=(ml-m2l).toString()+"px";
bl.style.color="black";
}