I'm working on a news ticker application as part of a company dashboard.
I'm basing the ticker on RumorMill ticker found
Instead of scrolling horizontally, mine is scrolling vertically, and because there may be a small number of items they get removed as soon as they clear the display area - which then can get them put back into the queue again (assuming it wasn't removed from the database).
My issue is with the timing/speed of the news items. Some items seem to be scrolling faster than others - with the chance that some could overlap.
I've been operating with the following equations:
s = d/t (general speed formula)
w = window height
h = item height
t = specified time on screen
t1 = actual time to target
The animation moving the item from window height (item clipped below the panel) to the item's height above the window.
w/t = s = (w+h)/t1
(w+h)/s = t1
Here is the code for the animation:
Any ideas on what might be causing the timing to be off?
I'm basing the ticker on RumorMill ticker found
Instead of scrolling horizontally, mine is scrolling vertically, and because there may be a small number of items they get removed as soon as they clear the display area - which then can get them put back into the queue again (assuming it wasn't removed from the database).
My issue is with the timing/speed of the news items. Some items seem to be scrolling faster than others - with the chance that some could overlap.
I've been operating with the following equations:
s = d/t (general speed formula)
w = window height
h = item height
t = specified time on screen
t1 = actual time to target
The animation moving the item from window height (item clipped below the panel) to the item's height above the window.
w/t = s = (w+h)/t1
(w+h)/s = t1
Here is the code for the animation:
Code:
Private Sub AnimateMove(ByVal e As FrameworkElement)
' Max Width/Height set in calling routine based on orientation
' of the scroll.
e.Measure(New Size(e.MaxWidth, e.MaxHeight))
'e.Measure(New Size(Double.PositiveInfinity, Double.PositiveInfinity))
Dim r As New Rect(e.DesiredSize)
e.Arrange(r)
Dim [from] As Double = If(_orientation = Controls.Orientation.Horizontal, Container.ActualWidth, Container.ActualHeight)
Dim elSize As Double = If(_orientation = Controls.Orientation.Horizontal, e.ActualWidth, e.ActualHeight)
Dim [to] As Double = 0 - elSize
Dim windowSpeed As Double = ([from] / Speed.TotalSeconds)
Dim newTime As Double = (([from] + elSize) / windowSpeed)
Dim actualDuration As New TimeSpan(0, 0, Convert.ToInt32(newTime))
Dim nextFire As Integer = Convert.ToInt32((elSize + SeperatorSize) / windowSpeed)
'This is what triggers the next item to be added to the container - and then animated with this subroutine
displayTimer.Stop()
displayTimer.Interval = New TimeSpan(0, 0, nextFire)
displayTimer.Start()
Dim ani As New TaggedDoubleAnimation
ani.From = [from]
ani.To = [to]
ani.Duration = New Duration(actualDuration)
ani.TargetElement = e
Dim depProp As DependencyProperty = If(_orientation = Controls.Orientation.Horizontal, TranslateTransform.XProperty, TranslateTransform.YProperty)
AddHandler ani.Completed, AddressOf ani_Completed
Dim trans As New TranslateTransform()
e.RenderTransform = trans
trans.BeginAnimation(depProp, ani, HandoffBehavior.Compose)
End Sub
Any ideas on what might be causing the timing to be off?