From d17652218a99be822ea7f384b9d90b6ec1d47476 Mon Sep 17 00:00:00 2001 From: Keisuke KATO Date: Sat, 17 Feb 2018 05:59:33 +0900 Subject: [PATCH] Fixed an error when previewing the first line with Markdown extension (#43835) --- extensions/markdown/media/main.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extensions/markdown/media/main.js b/extensions/markdown/media/main.js index 53ac317d851..a3128f30609 100644 --- a/extensions/markdown/media/main.js +++ b/extensions/markdown/media/main.js @@ -155,9 +155,10 @@ if (previous) { if (next) { const betweenProgress = (offset - window.scrollY - previous.element.getBoundingClientRect().top) / (next.element.getBoundingClientRect().top - previous.element.getBoundingClientRect().top); - return previous.line + betweenProgress * (next.line - previous.line); + const line = previous.line + betweenProgress * (next.line - previous.line); + return (0 <= line) ? line : 0; } else { - return previous.line; + return (0 <= previous.line) ? previous.line : 0; } } return null;