Skip to content

Commit

Permalink
no -1
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed May 1, 2024
1 parent 15a563a commit b2b0ae0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/textual/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def get_scroll_to_visible(
)

if top:
delta_y = top_ - window_top + 1
delta_y = top_ - window_top

elif not (
(window_bottom > top_ >= window_top)
Expand Down
9 changes: 4 additions & 5 deletions src/textual/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2675,7 +2675,7 @@ def scroll_to_widget(
else:
scroll_offset = container.scroll_to_region(
region,
spacing=widget.gutter + widget.dock_gutter,
spacing=widget.dock_gutter,
animate=animate,
speed=speed,
duration=duration,
Expand Down Expand Up @@ -2745,7 +2745,7 @@ def scroll_to_region(
"""
window = self.scrollable_content_region.at_offset(self.scroll_offset)
if spacing is not None:
region = region.grow(spacing)
window = window.shrink(spacing)

if window in region and not (top or center):
return Offset()
Expand All @@ -2762,15 +2762,14 @@ def clamp_delta(delta: Offset) -> Offset:
if center:
region_center_x, region_center_y = region.center
window_center_x, window_center_y = window.center

delta = clamp_delta(
Offset(
round(region_center_x - window_center_x),
round(region_center_y - window_center_y),
)
)
if origin_visible and (
region.shrink(spacing).offset not in window.translate(delta)
):
if origin_visible and (region.offset not in window.translate(delta)):
delta = clamp_delta(
Region.get_scroll_to_visible(window, region, top=True)
)
Expand Down

0 comments on commit b2b0ae0

Please sign in to comment.