From 136d895d155f28c2e75b3af206549acaa2a354ed Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Mon, 15 Feb 2021 09:42:51 +0100 Subject: Linter: Fix all lint errors Signed-off-by: Philip Molares --- public/js/lib/syncscroll.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'public/js/lib/syncscroll.js') diff --git a/public/js/lib/syncscroll.js b/public/js/lib/syncscroll.js index d492fbc9..f033d00d 100644 --- a/public/js/lib/syncscroll.js +++ b/public/js/lib/syncscroll.js @@ -155,12 +155,12 @@ const buildMap = _.throttle(buildMapInner, buildMapThrottle) // Optimizations are required only for big texts. function buildMapInner (callback) { if (!viewArea || !markdownArea) return - let i, offset, nonEmptyList, pos, a, b, _lineHeightMap, linesCount, acc, _scrollMap + let i, pos, a, b, acc - offset = viewArea.scrollTop() - viewArea.offset().top - _scrollMap = [] - nonEmptyList = [] - _lineHeightMap = [] + const offset = viewArea.scrollTop() - viewArea.offset().top + const _scrollMap = [] + const nonEmptyList = [] + const _lineHeightMap = [] viewTop = 0 viewBottom = viewArea[0].scrollHeight - viewArea.height() @@ -181,7 +181,7 @@ function buildMapInner (callback) { acc += Math.round(h / lineHeight) } _lineHeightMap.push(acc) - linesCount = acc + const linesCount = acc for (i = 0; i < linesCount; i++) { _scrollMap.push(-1) @@ -290,11 +290,12 @@ export function syncScrollToEdit (event, preventAnimate) { posTo += Math.ceil(posToNextDiff) } + let duration = 0 if (preventAnimate) { editArea.scrollTop(posTo) } else { const posDiff = Math.abs(scrollInfo.top - posTo) - var duration = posDiff / 50 + duration = posDiff / 50 duration = duration >= 100 ? duration : 100 editArea.stop(true, true).animate({ scrollTop: posTo @@ -331,11 +332,11 @@ export function syncScrollToView (event, preventAnimate) { } if (viewScrolling) return - let lineNo, posTo + let posTo let topDiffPercent, posToNextDiff const scrollInfo = editor.getScrollInfo() const textHeight = editor.defaultTextHeight() - lineNo = Math.floor(scrollInfo.top / textHeight) + const lineNo = Math.floor(scrollInfo.top / textHeight) // if reach the last line, will start lerp to the bottom const diffToBottom = (scrollInfo.top + scrollInfo.clientHeight) - (scrollInfo.height - textHeight) if (scrollInfo.height > scrollInfo.clientHeight && diffToBottom > 0) { @@ -350,11 +351,12 @@ export function syncScrollToView (event, preventAnimate) { posTo += Math.floor(posToNextDiff) } + let duration = 0 if (preventAnimate) { viewArea.scrollTop(posTo) } else { const posDiff = Math.abs(viewArea.scrollTop() - posTo) - var duration = posDiff / 50 + duration = posDiff / 50 duration = duration >= 100 ? duration : 100 viewArea.stop(true, true).animate({ scrollTop: posTo -- cgit v1.2.3