@happy-nut/monacori 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/viewer.client.js +12 -3
- package/package.json +1 -1
package/dist/viewer.client.js
CHANGED
|
@@ -509,6 +509,15 @@ function scheduleDiffScroll(row) {
|
|
|
509
509
|
// reflow-forcing scrollIntoView can run, so collapse them to one (latest element) per animation frame and
|
|
510
510
|
// use block:nearest (no per-row center-jump). Shared by the tree, source caret, and diff caret.
|
|
511
511
|
var pendingScrollEl = null, scrollElRaf = 0;
|
|
512
|
+
// Reveal `el` by keeping it ~fraction of the way down its scroller, scrolling minimally on EVERY move so the
|
|
513
|
+
// view follows the caret CONTINUOUSLY. scrollIntoView('nearest') instead leaves the view still until the
|
|
514
|
+
// caret reaches the edge and then jumps — stuttering ~every viewport while an arrow key is held.
|
|
515
|
+
function revealAt(el, scroller, fraction) {
|
|
516
|
+
if (!el) return;
|
|
517
|
+
if (!scroller || !scroller.clientHeight) { try { el.scrollIntoView({ block: 'nearest', inline: 'nearest' }); } catch (x) {} return; }
|
|
518
|
+
var off = el.getBoundingClientRect().top - scroller.getBoundingClientRect().top;
|
|
519
|
+
scroller.scrollTop += off - scroller.clientHeight * fraction;
|
|
520
|
+
}
|
|
512
521
|
function scheduleScrollIntoView(el) {
|
|
513
522
|
pendingScrollEl = el || null;
|
|
514
523
|
if (scrollElRaf) return;
|
|
@@ -897,7 +906,7 @@ function scheduleTreeFocus() {
|
|
|
897
906
|
if (treeFocusIndex < 0 || treeFocusIndex >= rows.length) return;
|
|
898
907
|
const el = rows[treeFocusIndex];
|
|
899
908
|
document.querySelectorAll('.tree-focus').forEach((e) => { if (e !== el) e.classList.remove('tree-focus'); });
|
|
900
|
-
if (el) { el.classList.add('tree-focus'); el.
|
|
909
|
+
if (el) { el.classList.add('tree-focus'); revealAt(el, document.querySelector('.sidebar-scroll'), 0.42); }
|
|
901
910
|
});
|
|
902
911
|
}
|
|
903
912
|
|
|
@@ -1583,7 +1592,7 @@ function scheduleDiffReveal(wrapper, side, ri) {
|
|
|
1583
1592
|
applyDiffSelection();
|
|
1584
1593
|
if (!t) return;
|
|
1585
1594
|
var row = diffRowAt(t.wrapper, t.side, t.ri);
|
|
1586
|
-
|
|
1595
|
+
revealAt(row, document.getElementById('diff2html-container'), 0.42);
|
|
1587
1596
|
});
|
|
1588
1597
|
}
|
|
1589
1598
|
function navEntryOf(kind) {
|
|
@@ -3318,7 +3327,7 @@ function scheduleSourceReveal(prev) {
|
|
|
3318
3327
|
var lines = f.content.split(/\r?\n/);
|
|
3319
3328
|
updateSourceCaret(p, lines, f.language || 'text');
|
|
3320
3329
|
var cl = document.querySelector('.source-row.cursor-line');
|
|
3321
|
-
|
|
3330
|
+
revealAt(cl, document.getElementById('source-body'), 0.42);
|
|
3322
3331
|
});
|
|
3323
3332
|
}
|
|
3324
3333
|
|