Skip to content

Commit

Permalink
Compute view offset relative to anim target
Browse files Browse the repository at this point in the history
This enables quickly tapping focus right-left to keep typing in the
current window while showing the next window.

Resolves #26
  • Loading branch information
YaLTeR committed Sep 30, 2023
1 parent a3aa5fc commit 6f8ad18
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1539,14 +1539,20 @@ impl<W: LayoutElement> Workspace<W> {

let current_x = self.view_pos();

let final_x = if let Some(anim) = &self.view_offset_anim {
current_x - self.view_offset + anim.to().round() as i32
} else {
current_x
};

self.active_column_idx = idx;

// A different column was activated; reset the flag.
self.activate_prev_column_on_removal = false;

let new_x = self.column_x(idx) - PADDING;
let new_view_offset = compute_new_view_offset(
current_x,
final_x,
self.working_area.size.w,
new_x,
self.columns[idx].size().w,
Expand Down Expand Up @@ -1661,10 +1667,17 @@ impl<W: LayoutElement> Workspace<W> {
if idx == self.active_column_idx {
// We might need to move the view to ensure the resized window is still visible.
let current_x = self.view_pos();

let final_x = if let Some(anim) = &self.view_offset_anim {
current_x - self.view_offset + anim.to().round() as i32
} else {
current_x
};

let new_x = self.column_x(idx) - PADDING;

let new_view_offset = compute_new_view_offset(
current_x,
final_x,
self.working_area.size.w,
new_x,
self.columns[idx].size().w,
Expand Down

0 comments on commit 6f8ad18

Please sign in to comment.