Stop endless scrolling
When a scroll is unable to complete by moving text up or down, the timer continues to run. Every tick it attempts to scroll the text. This happens if you are on the last paragraph and click scroll. The page scrolls upwards until it can no longer scroll. It locks there. The timer keeps trying to move the text, but that is not visible. When the user goes to the next section, the scroll is still running and will continue the scroll. If the new section is shorter than the previous section, the scroll will never stop. Fixes: #5
This commit is contained in:
@@ -206,6 +206,8 @@ class ReadDialog(QDialog, Ui_ReadDialog):
|
||||
if msPerTick < 3:
|
||||
msPerTick = 3
|
||||
self.target = value + delta
|
||||
if self.target > self.paraEdit.verticalScrollBar().maximum():
|
||||
self.target = self.paraEdit.verticalScrollBar().maximum() - 1
|
||||
timer = QTimer(self)
|
||||
timer.timeout.connect(self.softTick)
|
||||
timer.start(msPerTick)
|
||||
@@ -214,6 +216,7 @@ class ReadDialog(QDialog, Ui_ReadDialog):
|
||||
@pyqtSlot()
|
||||
def softTick(self) -> None:
|
||||
value = self.paraEdit.verticalScrollBar().value()
|
||||
maxValue = self.paraEdit.verticalScrollBar().maximum()
|
||||
sender: QTimer = cast(QTimer, self.sender())
|
||||
if self.pxPerTick < 0: # moving content up
|
||||
if value < self.target:
|
||||
|
||||
Reference in New Issue
Block a user