mirror of
https://github.com/alacritty/alacritty.git
synced 2026-12-01 01:14:32 +03:00
Relax horizontal scrolling
Apply horizontal scrolling when the angle between the axis X and (x, y) vector is lower than 25 degrees. Fixes #6711.
This commit is contained in:
1 parent
c682a357ec
commit
79ea8b9482
1 file changed
+9
-1
@@ -648,13 +648,21 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {
|
||||
let new_scroll_px_y = lines * self.ctx.size_info().cell_height();
|
||||
self.scroll_terminal(new_scroll_px_x as f64, new_scroll_px_y as f64);
|
||||
},
|
||||
MouseScrollDelta::PixelDelta(lpos) => {
|
||||
MouseScrollDelta::PixelDelta(mut lpos) => {
|
||||
match phase {
|
||||
TouchPhase::Started => {
|
||||
// Reset offset to zero.
|
||||
self.ctx.mouse_mut().accumulated_scroll = Default::default();
|
||||
},
|
||||
TouchPhase::Moved => {
|
||||
// When the angle between (x, 0) and (x, y) is lower than ~25 degrees
|
||||
// (cosine is larger that 0.9) we consider this scrolling as horizontal.
|
||||
if lpos.x.abs() / lpos.x.hypot(lpos.y) > 0.9 {
|
||||
lpos.y = 0.;
|
||||
} else {
|
||||
lpos.x = 0.;
|
||||
}
|
||||
|
||||
self.scroll_terminal(lpos.x, lpos.y);
|
||||
},
|
||||
_ => (),
|
||||
|
||||
Reference in new issue
Block a user