Implement horizontal scrolling

This commit is contained in:
Cameron Gutman
2023-02-20 16:00:03 -06:00
parent 5c844d3d1f
commit 0e40e4795a
+23
View File
@@ -474,6 +474,8 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
} }
CGPoint currentScrollTranslation = [gesture translationInView:self]; CGPoint currentScrollTranslation = [gesture translationInView:self];
{
short translationDeltaY = ((currentScrollTranslation.y - lastScrollTranslation.y) / self.bounds.size.height) * 120; // WHEEL_DELTA short translationDeltaY = ((currentScrollTranslation.y - lastScrollTranslation.y) / self.bounds.size.height) * 120; // WHEEL_DELTA
if (translationDeltaY != 0) { if (translationDeltaY != 0) {
LiSendHighResScrollEvent(translationDeltaY * 20); LiSendHighResScrollEvent(translationDeltaY * 20);
@@ -481,6 +483,16 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
} }
} }
{
short translationDeltaX = ((currentScrollTranslation.x - lastScrollTranslation.x) / self.bounds.size.width) * 120; // WHEEL_DELTA
if (translationDeltaX != 0) {
// Direction is reversed from vertical scrolling
LiSendHighResHScrollEvent(-translationDeltaX * 20);
lastScrollTranslation = currentScrollTranslation;
}
}
}
- (void)mouseWheelMovedDiscrete:(UIPanGestureRecognizer *)gesture { - (void)mouseWheelMovedDiscrete:(UIPanGestureRecognizer *)gesture {
switch (gesture.state) { switch (gesture.state) {
case UIGestureRecognizerStateBegan: case UIGestureRecognizerStateBegan:
@@ -497,10 +509,21 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
// Using velocityInView is 0 for discrete scroll events // Using velocityInView is 0 for discrete scroll events
// when scrolling very slowly, but translationInView does work. // when scrolling very slowly, but translationInView does work.
CGPoint currentScrollTranslation = [gesture translationInView:self]; CGPoint currentScrollTranslation = [gesture translationInView:self];
{
short translationDeltaY = currentScrollTranslation.y - lastScrollTranslation.y; short translationDeltaY = currentScrollTranslation.y - lastScrollTranslation.y;
if (translationDeltaY != 0) { if (translationDeltaY != 0) {
LiSendScrollEvent(translationDeltaY > 0 ? 1 : -1); LiSendScrollEvent(translationDeltaY > 0 ? 1 : -1);
} }
}
{
short translationDeltaX = currentScrollTranslation.x - lastScrollTranslation.x;
if (translationDeltaX != 0) {
// Direction is reversed from vertical scrolling
LiSendHScrollEvent(translationDeltaX < 0 ? 1 : -1);
}
}
lastScrollTranslation = currentScrollTranslation; lastScrollTranslation = currentScrollTranslation;
} }