mirror of
https://github.com/godotengine/godot.git
synced 2024-11-30 16:12:46 +00:00
Merge pull request #15127 from poke1024/smooth-scroll-play
Remove some lagginess from TextEdit's smooth scrolling
This commit is contained in:
commit
e3c744f9f1
@ -3139,6 +3139,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||
|
||||
void TextEdit::_scroll_up(real_t p_delta) {
|
||||
|
||||
if (scrolling && smooth_scroll_enabled && SGN(target_v_scroll - v_scroll->get_value()) != SGN(-p_delta))
|
||||
scrolling = false;
|
||||
|
||||
if (scrolling) {
|
||||
target_v_scroll = (target_v_scroll - p_delta);
|
||||
} else {
|
||||
@ -3149,8 +3152,12 @@ void TextEdit::_scroll_up(real_t p_delta) {
|
||||
if (target_v_scroll <= 0) {
|
||||
target_v_scroll = 0;
|
||||
}
|
||||
scrolling = true;
|
||||
set_physics_process(true);
|
||||
if (Math::abs(target_v_scroll - v_scroll->get_value()) < 1.0) {
|
||||
v_scroll->set_value(target_v_scroll);
|
||||
} else {
|
||||
scrolling = true;
|
||||
set_physics_process(true);
|
||||
}
|
||||
} else {
|
||||
v_scroll->set_value(target_v_scroll);
|
||||
}
|
||||
@ -3158,6 +3165,9 @@ void TextEdit::_scroll_up(real_t p_delta) {
|
||||
|
||||
void TextEdit::_scroll_down(real_t p_delta) {
|
||||
|
||||
if (scrolling && smooth_scroll_enabled && SGN(target_v_scroll - v_scroll->get_value()) != SGN(p_delta))
|
||||
scrolling = false;
|
||||
|
||||
if (scrolling) {
|
||||
target_v_scroll = (target_v_scroll + p_delta);
|
||||
} else {
|
||||
@ -3174,8 +3184,13 @@ void TextEdit::_scroll_down(real_t p_delta) {
|
||||
if (target_v_scroll > max_v_scroll) {
|
||||
target_v_scroll = max_v_scroll;
|
||||
}
|
||||
scrolling = true;
|
||||
set_physics_process(true);
|
||||
|
||||
if (Math::abs(target_v_scroll - v_scroll->get_value()) < 1.0) {
|
||||
v_scroll->set_value(target_v_scroll);
|
||||
} else {
|
||||
scrolling = true;
|
||||
set_physics_process(true);
|
||||
}
|
||||
} else {
|
||||
v_scroll->set_value(target_v_scroll);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user