Skip to content

Commit

Permalink
fix: smooth scroll performance issue(#183) (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ark2000 authored Sep 10, 2024
1 parent be716a5 commit 06d7aa3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions addons/panku_console/common/smooth_scroll/smooth_scroll.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,16 @@ func _gui_input(event: InputEvent) -> void:
scrollbar.value += step

func _process(delta: float) -> void:
content.size = Vector2(clip_container.size.x, 0)
content.position = Vector2.ZERO
# add a tiny optimization here
if not is_visible_in_tree(): return

# See https://github.com/Ark2000/PankuConsole/issues/183, looks quirky
# content.size = Vector2(clip_container.size.x, 0)
# content.position = Vector2.ZERO
content.size.x = clip_container.size.x
content.size.y = 0
content.position.y = 0

scrollbar.max_value = content.size.y
var scrollbar_value_max = max(0, scrollbar.max_value - clip_container.size.y)
scrollbar.value = lerp(scrollbar.value, clampf(scrollbar.value, 0.0, scrollbar_value_max), 0.2)
Expand Down

0 comments on commit 06d7aa3

Please sign in to comment.