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;
|
acc = 0;
|
||||||
var lines = editor.getValue().split('\n');
|
var lines = editor.getValue().split('\n');
|
||||||
|
var lineHeight = parseFloat(sourceLikeDiv.css('line-height'));
|
||||||
|
var div = sourceLikeDiv[0];
|
||||||
for (i = 0; i < lines.length; i++) {
|
for (i = 0; i < lines.length; i++) {
|
||||||
var str = lines[i];
|
var str = lines[i];
|
||||||
var h, lh;
|
var h, lh;
|
||||||
|
@ -211,9 +213,8 @@ function buildMapInner(syncBack) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceLikeDiv.text(str);
|
sourceLikeDiv.text(str);
|
||||||
h = parseFloat(sourceLikeDiv.css('height'));
|
h = parseFloat(div.clientHeight);
|
||||||
lh = parseFloat(sourceLikeDiv.css('line-height'));
|
acc += Math.round(h / lineHeight);
|
||||||
acc += Math.round(h / lh);
|
|
||||||
}
|
}
|
||||||
sourceLikeDiv.remove();
|
sourceLikeDiv.remove();
|
||||||
_lineHeightMap.push(acc);
|
_lineHeightMap.push(acc);
|
||||||
|
@ -260,7 +261,7 @@ function buildMapInner(syncBack) {
|
||||||
scrollMap = _scrollMap;
|
scrollMap = _scrollMap;
|
||||||
lineHeightMap = _lineHeightMap;
|
lineHeightMap = _lineHeightMap;
|
||||||
|
|
||||||
if(loaded && syncBack)
|
if (loaded && syncBack)
|
||||||
syncScrollToView();
|
syncScrollToView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue