Fixed scrolling with touchpad in vertical drum picker.

This commit is contained in:
23rd 2022-04-01 17:54:17 +03:00
parent 7fda14ccca
commit 6a7cbc545f
2 changed files with 20 additions and 5 deletions

View File

@ -135,13 +135,24 @@ void VerticalDrumPicker::handleWheelEvent(not_null<QWheelEvent*> e) {
if (direction) {
_animation.jumpToOffset(direction);
} else {
const auto delta = e->pixelDelta().y()
? e->pixelDelta().y()
: e->angleDelta().y();
increaseShift(delta / float64(_itemHeight));
if (e->phase() == Qt::ScrollEnd) {
if (const auto delta = e->pixelDelta().y(); delta) {
increaseShift(delta / float64(_itemHeight));
} else if (e->phase() == Qt::ScrollEnd) {
animationDataFromIndex();
_animation.jumpToOffset(0);
} else {
constexpr auto step = int(QWheelEvent::DefaultDeltasPerStep);
_touch.verticalDelta += e->angleDelta().y();
while (std::abs(_touch.verticalDelta) >= step) {
if (_touch.verticalDelta < 0) {
_touch.verticalDelta += step;
_animation.jumpToOffset(1);
} else {
_touch.verticalDelta -= step;
_animation.jumpToOffset(-1);
}
}
}
}
}

View File

@ -99,6 +99,10 @@ private:
bool clickDisabled = false;
} _mouse;
struct {
int verticalDelta = 0;
} _touch;
};
} // namespace Ui