diff --git a/Source/Editor/GUI/Timeline/GUI/Background.cs b/Source/Editor/GUI/Timeline/GUI/Background.cs index cc143e945..62c6b3b31 100644 --- a/Source/Editor/GUI/Timeline/GUI/Background.cs +++ b/Source/Editor/GUI/Timeline/GUI/Background.cs @@ -223,8 +223,16 @@ namespace FlaxEditor.GUI.Timeline.GUI // Zoom in/out if (IsMouseOver && Root.GetKey(KeyboardKeys.Control)) { - // TODO: preserve the view center point for easier zooming + var locationTimeOld = _timeline.MediaBackground.PointFromParent(_timeline, _timeline.Size * 0.5f).X; + var frame = (locationTimeOld - Timeline.StartOffset * 2.0f) / _timeline.Zoom / Timeline.UnitsPerSecond * _timeline.FramesPerSecond; + _timeline.Zoom += delta * 0.1f; + + var locationTimeNew = frame / _timeline.FramesPerSecond * Timeline.UnitsPerSecond * _timeline.Zoom + Timeline.StartOffset * 2.0f; + var locationTimeDelta = locationTimeNew - locationTimeOld; + var scroll = _timeline.MediaBackground.HScrollBar; + if (scroll.Visible && scroll.Enabled) + scroll.TargetValue += locationTimeDelta; return true; }