You could define a linear interpolation function like this:
float lerp(float value, float start, float end)
{
return start + (end - start) * value;
}
Then set the center of the View with sf::View::SetCenter(mouseX, mouseY) and zoom into that position with the result of the lerp with sf::View::Zoom().
Some pseudo code:
targetzoom = 0
currentzoom = 0
previouszoom = 0
zooming = false
void update()
{
if (move mousewheel)
{
zooming = true
targetzoom = 0.5
currentzoom = 0
}
if (zooming)
{
currentzoom = lerp(0.01, currentzoom, targetzoom)
view.Zoom(currentzoom - previouszoom) // Zoom is relative.
previouszoom = currentzoom
if (abs(targetzoom - currentzoom) < 0.1) // Lerp will never reach the target.
zooming = false
}
}