Zoom behavior in Timeline

1 Answer 48 Views
TimeLine
Eran
Top achievements
Rank 1
Eran asked on 24 Aug 2021, 02:25 PM

I am trying to achieve the following behavior:

1. Wheel will control vertical scroll

2. Horizontal scroll will be visible with resize controls (zoom in and zoom out)

 

Is this possible?

1 Answer, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 27 Aug 2021, 10:08 AM

Hello Eran,

In order to achieve the desired behavior, you can set the ScrollMode of the RadTimeLine to ScrollAndZoom (which is also the default value), handle the PreviewMouseWheel event and manually scroll the timeline up/down. Here is an example of how that might look like:

private void RadTimeline_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            var scrollBar = this.timeLine.ChildrenOfType<TimelineScrollBar>().FirstOrDefault(s => s.Name == "Part_VerticalSlider");
            e.Handled = true;
            if (scrollBar != null)
            {
                if(e.Delta > 0)
                {
                    if (scrollBar.SelectionStart < 0.001)
                    {
                        return;
                    }
                    
                    scrollBar.Selection = new SelectionRange<double>(scrollBar.SelectionStart - 0.1, scrollBar.SelectionEnd - 0.1);

                }
                else
                {
                    if (scrollBar.SelectionEnd == 1)
                    {
                        return;
                    }
                    scrollBar.Selection = new SelectionRange<double>(scrollBar.SelectionStart + 0.1, scrollBar.SelectionEnd + 0.1);

                }

            }
        }

I hope you find this information helpful. Let me know, if I can be of any further assistance.

Regards,
Vladimir Stoyanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Eran
Top achievements
Rank 1
commented on 29 Aug 2021, 01:17 PM

Works perfect

Thanks

Tags
TimeLine
Asked by
Eran
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Share this question
or