mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 03:06:31 -05:00
Optimized syncscroll.js buildMap, make it faster
This commit is contained in:
parent
f8ef5341c7
commit
17f89e9bd3
1 changed files with 5 additions and 4 deletions
|
@ -199,6 +199,8 @@ function buildMapInner(syncBack) {
|
|||
|
||||
acc = 0;
|
||||
var lines = editor.getValue().split('\n');
|
||||
var lineHeight = parseFloat(sourceLikeDiv.css('line-height'));
|
||||
var div = sourceLikeDiv[0];
|
||||
for (i = 0; i < lines.length; i++) {
|
||||
var str = lines[i];
|
||||
var h, lh;
|
||||
|
@ -211,9 +213,8 @@ function buildMapInner(syncBack) {
|
|||
}
|
||||
|
||||
sourceLikeDiv.text(str);
|
||||
h = parseFloat(sourceLikeDiv.css('height'));
|
||||
lh = parseFloat(sourceLikeDiv.css('line-height'));
|
||||
acc += Math.round(h / lh);
|
||||
h = parseFloat(div.clientHeight);
|
||||
acc += Math.round(h / lineHeight);
|
||||
}
|
||||
sourceLikeDiv.remove();
|
||||
_lineHeightMap.push(acc);
|
||||
|
|
Loading…
Reference in a new issue