Skip to content

Commit f7a85aa

Browse files
committed
fix: smooth scroll performance issue(#183)
1 parent a6956d3 commit f7a85aa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

addons/panku_console/common/smooth_scroll/smooth_scroll.gd

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,16 @@ func _gui_input(event: InputEvent) -> void:
2626
scrollbar.value += step
2727

2828
func _process(delta: float) -> void:
29-
content.size = Vector2(clip_container.size.x, 0)
30-
content.position = Vector2.ZERO
29+
# add a tiny optimization here
30+
if not is_visible_in_tree(): return
31+
32+
# See https://github.com/Ark2000/PankuConsole/issues/183, looks quirky
33+
# content.size = Vector2(clip_container.size.x, 0)
34+
# content.position = Vector2.ZERO
35+
content.size.x = clip_container.size.x
36+
content.size.y = 0
37+
content.position.y = 0
38+
3139
scrollbar.max_value = content.size.y
3240
var scrollbar_value_max = max(0, scrollbar.max_value - clip_container.size.y)
3341
scrollbar.value = lerp(scrollbar.value, clampf(scrollbar.value, 0.0, scrollbar_value_max), 0.2)

0 commit comments

Comments
 (0)