fix scroll sync on osx ff/chrome

This commit is contained in:
ed 2020-05-14 00:03:01 +02:00
parent 5d6a740947
commit 27cb1d4fc7
2 changed files with 23 additions and 9 deletions

View file

@ -45,9 +45,12 @@
color: #444; color: #444;
background: #f7f7f7; background: #f7f7f7;
border: 1px solid #999; border: 1px solid #999;
outline: none;
padding: 0;
margin: 0;
font-family: 'consolas', monospace, monospace; font-family: 'consolas', monospace, monospace;
white-space: pre-wrap; white-space: pre-wrap;
word-break: break-all; word-break: break-word;
overflow-wrap: break-word; overflow-wrap: break-word;
word-wrap: break-word; /*ie*/ word-wrap: break-word; /*ie*/
overflow-y: scroll; overflow-y: scroll;
@ -62,8 +65,8 @@ html.dark #mt {
} }
#mtr { #mtr {
position: absolute; position: absolute;
top: 1px; top: 0;
left: 1px; left: 0;
} }
#save.force-save { #save.force-save {
color: #400; color: #400;
@ -98,8 +101,4 @@ html.dark #helpbox {
border-width: 1px 0; border-width: 1px 0;
} }
/* dbg: # mt {opacity: .5;top:1px}
#mt {
opacity: .5;
}
*/

View file

@ -48,6 +48,10 @@ function genmap(dom) {
while (ln > ret.length) while (ln > ret.length)
ret.push(null); ret.push(null);
if (parent_y == 0 && n.offsetTop == 0)
//console.log('awawa');
continue;
ret.push(parent_y + n.offsetTop); ret.push(parent_y + n.offsetTop);
} }
return ret; return ret;
@ -99,7 +103,7 @@ redraw = (function () {
var y = (dom_hbar.offsetTop + dom_hbar.offsetHeight) + 'px'; var y = (dom_hbar.offsetTop + dom_hbar.offsetHeight) + 'px';
dom_wrap.style.top = y; dom_wrap.style.top = y;
dom_swrap.style.top = y; dom_swrap.style.top = y;
dom_ref.style.width = (dom_src.offsetWidth - 4) + 'px'; dom_ref.style.width = getComputedStyle(dom_src).offsetWidth + 'px';
map_src = genmap(dom_ref); map_src = genmap(dom_ref);
map_pre = genmap(dom_pre); map_pre = genmap(dom_pre);
dbg(document.body.clientWidth + 'x' + document.body.clientHeight); dbg(document.body.clientWidth + 'x' + document.body.clientHeight);
@ -615,3 +619,14 @@ action_stack = (function () {
_ref: ref _ref: ref
} }
})(); })();
/*
document.getElementById('help').onclick = function () {
var c1 = getComputedStyle(dom_src).cssText.split(';');
var c2 = getComputedStyle(dom_ref).cssText.split(';');
var max = Math.min(c1.length, c2.length);
for (var a = 0; a < max; a++)
if (c1[a] !== c2[a])
console.log(c1[a] + '\n' + c2[a]);
}
*/