Skip to content

Commit 2212a09

Browse files
committed
feat: add button-repeat scroll with animation (#1088)
1 parent f179a68 commit 2212a09

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

qfluentwidgets/components/widgets/cycle_list_widget.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def setScrollButtonRepeatEnabled(self, isEnabled: bool):
207207
self.upButton.setAutoRepeat(isEnabled)
208208
self.downButton.setAutoRepeat(isEnabled)
209209

210-
def _scrollWithAnimation(self, delta: int):
210+
def _scrollWithAnimation(self, index: int):
211211
""" scroll with adaptive animation """
212212
t = QTime.currentTime()
213213
elapsed = self._lastScrollTime.msecsTo(t)
@@ -220,17 +220,16 @@ def _scrollWithAnimation(self, delta: int):
220220
duration, easing = 250, QEasingCurve.OutQuad
221221

222222
self.vScrollBar.setScrollAnimation(duration, easing)
223-
index = self.currentIndex() + delta
224223
self.setCurrentIndex(index)
225224
self.scrollToItem(self.currentItem())
226225

227226
def scrollDown(self):
228227
""" scroll down an item """
229-
self._scrollWithAnimation(1)
228+
self._scrollWithAnimation(self.currentIndex() + 1)
230229

231230
def scrollUp(self):
232231
""" scroll up an item """
233-
self._scrollWithAnimation(-1)
232+
self._scrollWithAnimation(self.currentIndex() - 1)
234233

235234
def _setButtonsVisible(self, visible: bool):
236235
""" set scroll buttons visibility """

0 commit comments

Comments
 (0)