aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-05-22 14:17:27 +0200
committerdec05eba <dec05eba@protonmail.com>2021-05-22 14:17:27 +0200
commitcd540a6419c6606688cb2d6152149f1a4d8e030f (patch)
tree0e83df1ea972ee65ecc5842cc130659cc0b0641a /src
parent6eee3c3782047cae7ec07737c695566ae26ea3be (diff)
Better scroll logic smoothness
Diffstat (limited to 'src')
-rw-r--r--src/Body.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index 24be25b..859b20f 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -625,8 +625,8 @@ namespace QuickMedia {
if(selected_item == last_visible_item)
target_scroll -= selected_item_height;
const double scroll_diff = target_scroll - extra_scroll_current;
- const double scroll_move_speed = 25.0;
- extra_scroll_current += (scroll_diff * std::min(1.0, 0.007f * scroll_move_speed));
+ const double scroll_move_speed = (frame_time > 0.010f ? 10.0f : 15.0f);
+ extra_scroll_current += (scroll_diff * std::min(1.0, frame_time * scroll_move_speed));
double scroll_smooth_diff = extra_scroll_current - prev_extra_scroll;
prev_extra_scroll = extra_scroll_current;
@@ -805,15 +805,17 @@ namespace QuickMedia {
instant_move = true;
}
+ const float speed = frame_time > 0.010f ? 35.0f : 50.0f;
+
const float item_background_prev_pos_y = item_background.get_position().y;
const float item_background_pos_diff = item_background_target_pos_y - item_background_prev_pos_y;
- float item_background_move_speed = instant_move ? 1000.0f : 50.0f;
- item_background.set_position(sf::Vector2f(pos.x, item_background_prev_pos_y + (item_background_pos_diff * std::min(1.0f, 0.007f * item_background_move_speed))));
+ const float item_background_move_speed = instant_move ? 1000.0f : speed;
+ item_background.set_position(sf::Vector2f(pos.x, item_background_prev_pos_y + (item_background_pos_diff * std::min(1.0f, frame_time * item_background_move_speed))));
const float item_background_prev_height = item_background.get_size().y;
const float item_background_height_diff = item_background_target_height - item_background_prev_height;
- const float item_background_height_speed = instant_move ? 1000.0f : 50.0f;
- item_background.set_size(sf::Vector2f(size.x, item_background_prev_height + (item_background_height_diff * std::min(1.0f, 0.007f * item_background_height_speed))));
+ const float item_background_height_speed = instant_move ? 1000.0f : speed;
+ item_background.set_size(sf::Vector2f(size.x, item_background_prev_height + (item_background_height_diff * std::min(1.0f, frame_time * item_background_height_speed))));
if(render_selected_item_bg)
item_background.draw(window);