From 53e600811ad9fd840fb5eef8a88923fa938bc684 Mon Sep 17 00:00:00 2001 From: ketmar Date: Mon, 25 Sep 2017 18:58:42 +0000 Subject: [PATCH] cosmetix FossilOrigin-Name: b7e6ea41da705b2d4aca97de370021c530b4564d6edc4b7646157c0e04f70cb3 --- xreader.d | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/xreader.d b/xreader.d index 967d880..7a3f052 100644 --- a/xreader.d +++ b/xreader.d @@ -1008,18 +1008,24 @@ void run () { // smooth scrolling if (formatWorks == 0) { enum Delta = 92*2; - if (toMove < 0) { - int sc = -toMove; - if (sc > Delta) sc = Delta; - hardScrollBy(-sc); - toMove += sc; - nextFadeTime = ctt+500.msecs; - refresh(); - } else if (toMove > 0) { - int sc = toMove; - if (sc > Delta) sc = Delta; - hardScrollBy(sc); - toMove -= sc; + if (toMove != 0) { + import std.math : abs; + immutable int sign = (toMove < 0 ? -1 : 1); + // change speed + if (arrowSpeed == 0) arrowSpeed = 8; + if (abs(toMove) <= arrowSpeed) { + arrowSpeed /= 2; + if (arrowSpeed < 4) arrowSpeed = 4; + } else { + arrowSpeed *= 2; + if (arrowSpeed > Delta) arrowSpeed = Delta; + } + // calc move distance + int sc = arrowSpeed; + if (sc > abs(toMove)) sc = abs(toMove); + hardScrollBy(sc*sign); + toMove -= sc*sign; + if (toMove == 0) arrowSpeed = 0; nextFadeTime = ctt+500.msecs; refresh(); } else if (arrowDir) { -- 2.11.4.GIT