| skipped 647 lines |
648 | 648 | | let new_scroll_px_y = lines * self.ctx.size_info().cell_height(); |
649 | 649 | | self.scroll_terminal(new_scroll_px_x as f64, new_scroll_px_y as f64); |
650 | 650 | | }, |
651 | | - | MouseScrollDelta::PixelDelta(lpos) => { |
| 651 | + | MouseScrollDelta::PixelDelta(mut lpos) => { |
652 | 652 | | match phase { |
653 | 653 | | TouchPhase::Started => { |
654 | 654 | | // Reset offset to zero. |
655 | 655 | | self.ctx.mouse_mut().accumulated_scroll = Default::default(); |
656 | 656 | | }, |
657 | 657 | | TouchPhase::Moved => { |
| 658 | + | // When the angle between (x, 0) and (x, y) is lower than ~25 degrees |
| 659 | + | // (cosine is larger that 0.9) we consider this scrolling as horizontal. |
| 660 | + | if lpos.x.abs() / lpos.x.hypot(lpos.y) > 0.9 { |
| 661 | + | lpos.y = 0.; |
| 662 | + | } else { |
| 663 | + | lpos.x = 0.; |
| 664 | + | } |
| 665 | + | |
658 | 666 | | self.scroll_terminal(lpos.x, lpos.y); |
659 | 667 | | }, |
660 | 668 | | _ => (), |
| skipped 865 lines |