From 27cb1d4fc7e49f771ba24dcf8e088516033e56cf Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 14 May 2020 00:03:01 +0200 Subject: [PATCH] fix scroll sync on osx ff/chrome --- copyparty/web/md2.css | 15 +++++++-------- copyparty/web/md2.js | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/copyparty/web/md2.css b/copyparty/web/md2.css index 80f02123..67fcc6be 100644 --- a/copyparty/web/md2.css +++ b/copyparty/web/md2.css @@ -45,9 +45,12 @@ color: #444; background: #f7f7f7; border: 1px solid #999; + outline: none; + padding: 0; + margin: 0; font-family: 'consolas', monospace, monospace; white-space: pre-wrap; - word-break: break-all; + word-break: break-word; overflow-wrap: break-word; word-wrap: break-word; /*ie*/ overflow-y: scroll; @@ -62,8 +65,8 @@ html.dark #mt { } #mtr { position: absolute; - top: 1px; - left: 1px; + top: 0; + left: 0; } #save.force-save { color: #400; @@ -98,8 +101,4 @@ html.dark #helpbox { border-width: 1px 0; } -/* dbg: -#mt { - opacity: .5; -} -*/ +# mt {opacity: .5;top:1px} diff --git a/copyparty/web/md2.js b/copyparty/web/md2.js index 8e4409f4..a86513d4 100644 --- a/copyparty/web/md2.js +++ b/copyparty/web/md2.js @@ -48,6 +48,10 @@ function genmap(dom) { while (ln > ret.length) ret.push(null); + if (parent_y == 0 && n.offsetTop == 0) + //console.log('awawa'); + continue; + ret.push(parent_y + n.offsetTop); } return ret; @@ -99,7 +103,7 @@ redraw = (function () { var y = (dom_hbar.offsetTop + dom_hbar.offsetHeight) + 'px'; dom_wrap.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_pre = genmap(dom_pre); dbg(document.body.clientWidth + 'x' + document.body.clientHeight); @@ -615,3 +619,14 @@ action_stack = (function () { _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]); +} +*/ \ No newline at end of file