Commit 88af9112 authored by Scott Chen's avatar Scott Chen Committed by Commit Bot

MD Extensions: remove smooth scrolling for long files

Bug: 781335
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Id8bd8fca8d4adea95561d454783c45d40872edbb
Reviewed-on: https://chromium-review.googlesource.com/816059
Commit-Queue: Scott Chen <scottchen@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523284}
parent ad4f3d69
......@@ -65,10 +65,20 @@ cr.define('extensions', function() {
/** @private */
onHighlightChanged_: function() {
// Smooth scroll the highlight to roughly the middle.
const CSS_LINE_HEIGHT = 20;
const SCROLL_LOC_THRESHOLD = 100;
// Scroll the highlight to roughly the middle.
const targetTop = this.$.highlight.offsetTop - this.clientHeight * 0.5;
// Smooth scrolling if moving within ~100 LOC, otherwise just jump to it.
const behavior =
Math.abs(this.$['scroll-container'].scrollTop - targetTop) <
(CSS_LINE_HEIGHT * SCROLL_LOC_THRESHOLD) ?
'smooth' :
'auto';
this.$['scroll-container'].scrollTo({
top: this.$.highlight.offsetTop - this.clientHeight * 0.5,
behavior: 'smooth',
top: targetTop,
behavior: behavior,
});
},
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment