@@ -37,10 +37,11 @@ namespace Rml {
3737static constexpr float AUTOSCROLL_SPEED_FACTOR = 0 .09f ;
3838static constexpr float AUTOSCROLL_DEADZONE = 10 .0f ; // [dp]
3939
40- static constexpr float SMOOTHSCROLL_WINDOW_SIZE = 50 .f; // The window where smoothing is applied, as a distance from scroll start and end. [dp]
40+ static constexpr float SMOOTHSCROLL_WINDOW_SIZE = 100 .f; // The window where smoothing is applied, as a distance from scroll start and end. [dp]
4141static constexpr float SMOOTHSCROLL_MAX_VELOCITY = 10'000 .f; // [dp/s]
4242static constexpr float SMOOTHSCROLL_VELOCITY_CONSTANT = 800 .f; // [dp/s]
4343static constexpr float SMOOTHSCROLL_VELOCITY_SQUARE_FACTOR = 0 .05f ;
44+ static constexpr float SMOOTHSCROLL_FIRST_FRAME_DELTA_TIME_MIN = 1 .f / 100 .f; // To make the scroll feel a bit more responsive. [s]
4445
4546// Factor to multiply friction by before applying to velocity.
4647static constexpr float INERTIA_FRICTION_FACTOR = 5 .0f ;
@@ -79,8 +80,8 @@ static Vector2f CalculateSmoothscrollVelocity(Vector2f target_delta, Vector2f sc
7980 const Vector2f alpha_in = Math::Min (scrolled_distance / SMOOTHSCROLL_WINDOW_SIZE, Vector2f (1 .f ));
8081 const Vector2f alpha_out = Math::Min (target_delta_abs / SMOOTHSCROLL_WINDOW_SIZE, Vector2f (1 .f ));
8182 const Vector2f smooth_window = {
82- 0 .2f + 0 .8f * tween (alpha_in.x ) * tween (alpha_out.x ),
83- 0 .2f + 0 .8f * tween (alpha_in.y ) * tween (alpha_out.y ),
83+ 0 .35f + 0 .65f * tween (alpha_in.x ) * tween (alpha_out.x ),
84+ 0 .35f + 0 .65f * tween (alpha_in.y ) * tween (alpha_out.y ),
8485 };
8586
8687 const Vector2f velocity_constant = Vector2f (SMOOTHSCROLL_VELOCITY_CONSTANT);
@@ -194,6 +195,9 @@ void ScrollController::UpdateSmoothscroll(float dt, float dp_ratio)
194195 const Vector2f target_delta = Vector2f (smoothscroll_target_distance - smoothscroll_scrolled_distance);
195196 const Vector2f velocity = CalculateSmoothscrollVelocity (target_delta, smoothscroll_scrolled_distance, dp_ratio);
196197
198+ if (smoothscroll_scrolled_distance == Vector2f{0 })
199+ dt = Math::Max (dt, SMOOTHSCROLL_FIRST_FRAME_DELTA_TIME_MIN);
200+
197201 Vector2f scroll_distance_fractional = smoothscroll_speed_factor * velocity * dt + smoothscroll_accumulated_fractional_distance;
198202
199203 Vector2f scroll_distance_integral;
0 commit comments