diff --git a/Libraries/LibWeb/CSS/Interpolation.cpp b/Libraries/LibWeb/CSS/Interpolation.cpp index 36579237f6b..b60608ce6f8 100644 --- a/Libraries/LibWeb/CSS/Interpolation.cpp +++ b/Libraries/LibWeb/CSS/Interpolation.cpp @@ -360,8 +360,15 @@ static FloatVector4 slerp(FloatVector4 const& from, FloatVector4 const& to, floa auto theta = acosf(product); auto w = sinf(delta * theta) / sqrtf(1 - (product * product)); + auto from_multiplier = cosf(delta * theta) - (product * w); - return from * (cosf(delta * theta) - (product * w)) + to * w; + if (abs(w) < AK::NumericLimits::epsilon()) + return from * from_multiplier; + + if (abs(from_multiplier) < AK::NumericLimits::epsilon()) + return to * w; + + return from * from_multiplier + to * w; } static RefPtr interpolate_rotate(DOM::Element& element, CalculationContext calculation_context, StyleValue const& a_from, StyleValue const& a_to, float delta, AllowDiscrete allow_discrete)