Forum > Packages and Libraries

ScrollingText and text speed

(1/3) > >>

ScrollingText, unfortunately, does not have a property that allows you to adjust the speed of scrolling text. This property is very much lacking. I spoke to the author some time ago and he told me that there are currently no plans to develop this component, but he showed me how to fix the component. That's why I made a patch. I have a request to @wp to check and add it to the repository if it's ok.

Due to the many formatting changes it is hard to find out what the essential changes are. My impression is that you define a new property "ScrollSpeed", add a setter method for it ("SetScrollSpeed") which sets the timer interval and initialize the timer in Create by the scrollspeed default value rather than the hard-coded "30". Is this correct? Did I miss anything? There is no way for the user to change the scrollspeed at runtime while scrolling is active (that's what I am missing most)?

The formatting changes are due to the fact that the original code didn't have it done, I just instinctively did the JEDI Code Format. Sorry to unintentionally hindered your analysis. Such changes are exactly what you described.

Update: I read your post again. But You can change the speed at runtime while scrolling is active - I don't know what you meant?


--- Quote from: kkuba on June 16, 2022, 12:09:08 pm ---But You can change the speed at runtime while scrolling is active - I don't know what you meant?

--- End quote ---
How can the user change it? Click into the form or press some key to increase the speed stepwise? Or drag with the mouse?

BTW, a note about words: you call the new property "ScrollSpeed". When a speed has a high value, something changes quickly, and so I'd expect a fast scrolling effect. But your speed value is assigned to the timer's interval. When the timer.Interval is increased it actually is triggered less often, i.e. scrolling become slower in spite of the higher "speed" value. I think nobody wants to set the Timer.Interval with the precision of milliseconds. Therefore, I'd propose to keep the property name "ScrollSpeed", but introduce a conversion table from speed values to milliseconds, e.g.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type  TScrollSpeed = 1..7;;const  // ms for Timer.Interval  SCROLL_INTERVAL: Array[TScrollSpeed] of Integer = (    200, 100, 50, 30, 25, 20, 10  );  constructor TScrollingText.Create(AOwner: TComponent);begin  inherited Create(AOwner);  ...  FScrollSpeed := 4;  FTimer.Interval := SCROLL_INTERVAL[FScrollSpeed];  ...end; procedure TScrollingText.SetScrollSpeed(Speed: TScrollSpeed);begin  FScrollSpeed := Speed;  FTimer.Interval := SCROLL_INTERVAL[FScrollSpeed];end;

And now I understand what you meant. What you write is actually not possible - but thanks to this amendment I change the value from e.g. a slider.
Of course what you propose is "prettier" code, so let's put it that way.
Overall thanks for improving the patch.  It seems that what we have done here is generally needed. Maybe you would submit @GetMem this fix to OPM


[0] Message Index

[#] Next page

Go to full version