Added ability to provide delta to DraggingScrollManager.

This commit is contained in:
23rd 2022-03-14 17:36:51 +03:00
parent 6e6ba5a149
commit 443191045b
2 changed files with 15 additions and 10 deletions

View file

@ -22,16 +22,8 @@ void DraggingScrollManager::scrollByTimer() {
_scrolls.fire_copy(d); _scrolls.fire_copy(d);
} }
void DraggingScrollManager::checkDeltaScroll( void DraggingScrollManager::checkDeltaScroll(int delta) {
const QPoint &point, _delta = delta;
int top,
int bottom) {
const auto diff = point.y() - top;
_delta = (diff < 0)
? diff
: (point.y() >= bottom)
? (point.y() - bottom + 1)
: 0;
if (_delta) { if (_delta) {
_timer.callEach(15); _timer.callEach(15);
} else { } else {
@ -39,6 +31,18 @@ void DraggingScrollManager::checkDeltaScroll(
} }
} }
void DraggingScrollManager::checkDeltaScroll(
const QPoint &point,
int top,
int bottom) {
const auto diff = point.y() - top;
checkDeltaScroll((diff < 0)
? diff
: (point.y() >= bottom)
? (point.y() - bottom + 1)
: 0);
}
void DraggingScrollManager::cancel() { void DraggingScrollManager::cancel() {
_timer.cancel(); _timer.cancel();
} }

View file

@ -17,6 +17,7 @@ class DraggingScrollManager final {
public: public:
DraggingScrollManager(); DraggingScrollManager();
void checkDeltaScroll(int delta);
void checkDeltaScroll(const QPoint &point, int top, int bottom); void checkDeltaScroll(const QPoint &point, int top, int bottom);
void cancel(); void cancel();