Smoother scrolling w/ deceleration for LC fields

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Smoother scrolling w/ deceleration for LC fields

Post by bn » Mon Apr 18, 2022 5:04 pm

A while ago there was a discussion on the use-list to get smoother scrolling and decelerating scrolling for LC fields.
https://quality.livecode.com/show_bug.cgi?id=19759
and a an old discussion on the use-list
http://lists.runrev.com/pipermail/use-l ... 96772.html
My script is based on above proposal by John Miskimins but with added deceleration.

Here is my take on this.
Feedback welcome, especially on slower computers.

Kind regards
Bernd
Attachments
smoothScrolling_0_2.livecode.zip
(5.03 KiB) Downloaded 87 times

stam
Posts: 2683
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Smoother scrolling w/ deceleration for LC fields

Post by stam » Mon Apr 18, 2022 5:50 pm

Hi Bernd,

i tested your stack on my mac (intel i7 mbp, macOS 12.3.1 Monterey, LC 10.0 DP3) but there were problems with etc 'smooth scrolling' window; it's a lot slower and laggier that the normal scroll. By slower i don't just mean scroll speed but how much of the window is scrolled for the same movement on the trackpad is much less and on a 'free scroll' it travels much less and with variable scrolling speed...

The version i have doesn't seem useable i'm afraid...

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Smoother scrolling w/ deceleration for LC fields

Post by bn » Mon Apr 18, 2022 6:25 pm

Hi Stam,

thanks for the feedback. On my M1 MacBookPro it scrolls quite nicely. That is why I was very interested in feedback.

Could you try to change some parameters? kCutOff to 150 and kDiv to 15 and tell me if that is better?

Code: Select all

constant kCutOff = 150 -- milliseconds between rawKeyDown, below decelerating scrolling kicks in
constant kDiv = 15 -- used to adapt stepsize to scrolling speed
Kind regards
Bernd

stam
Posts: 2683
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Smoother scrolling w/ deceleration for LC fields

Post by stam » Tue Apr 19, 2022 9:37 am

No sadly these changes don't improve performance, possibly it's worse.

I'll try and do a screen recording this evening or tomorrow, don't have time right now...

regards
Stam

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Smoother scrolling w/ deceleration for LC fields

Post by mrcoollion » Tue Apr 19, 2022 10:33 am

On Windows Laptop it works nice.
Slow scrolling is with small steps and fast scrolling is with large steps.
FYI: I do have a very fast laptop.

Regards,

Paul

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Smoother scrolling w/ deceleration for LC fields

Post by richmond62 » Tue Apr 19, 2022 11:00 am

You can never be too careful:
-
LCfieldsF.jpg

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9665
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Smoother scrolling w/ deceleration for LC fields

Post by dunbarx » Tue Apr 19, 2022 2:23 pm

Bernd.

iMac 27 4GHz Quad I7 on Catalina.

Took me a moment to look at the handlers to see that one should not use the scrollbar to do the scrolling, but rather the scrollwheel on the mouse.

I see a certain difference between the two fields, but not so much that I would rush to use the "smooth" one.

But why not play around with something like this?

Code: Select all

on rawKeyDown tkey
if tKey = 65308 then set the scroll of me to the scroll of me +  5 else set the scroll of me to the scroll of me - 5
end rawKeyDown
The fun thing here would be to change the "5" (an arbitrary value) to a larger one if the scroll wheel was moved more quickly.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9665
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Smoother scrolling w/ deceleration for LC fields

Post by dunbarx » Tue Apr 19, 2022 3:05 pm

I tried a few things, none of which seem to work. The idea is to detect the rate of scroll wheel movement, fast or slow. There does not seem to be a "scrollWheelRate" message.

Code: Select all

on rawKeyDown tkey
   get the milliseconds
   if tKey = 65308 then set the scroll of me to the scroll of me +  5 else set the scroll of me to the scroll of me - 5
   put the milliseconds - it into fld "ss"
end rawKeyDown
The number in fld "ss" (about 25) does not change much regardless of the scrollwheel speed. I was hoping that I could exploit a difference there to change the arbitrary "5", hard-coded in the handler, so that a faster wheel rate would scroll more quickly.

Still playing....

Craig

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Smoother scrolling w/ deceleration for LC fields

Post by bn » Tue Apr 19, 2022 6:51 pm

Craig,

Apparently the code does work differently on different processors (on slower ones less well). It seems to work well for @Paul.

The whole point of the exercise was to add deceleration to mouse-wheel scrolling like native fields scroll.
The main difference would be that towards the end of a scroll the amount of scrolling goes down. You should see the effect also when using the mouse-wheel/touchpad to scroll slowly.
The field with non-smooth scrolling uses a fixed amount of pixels when scrolling, for me it is about 97 pixels up or down. There is no code interfering with what Livecode thinks it should scroll.

I guess we will have to wait until Livecode somehow hooks into the operating system and adapts scrolling accordingly.

Kind regards
Bernd

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Smoother scrolling w/ deceleration for LC fields

Post by richmond62 » Tue Apr 19, 2022 6:54 pm

Am I missing something?
-
SShot 2022-04-19 at 20.53.52.png

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Smoother scrolling w/ deceleration for LC fields

Post by bn » Tue Apr 19, 2022 6:57 pm

richmond62 wrote:
Tue Apr 19, 2022 6:54 pm
Am I missing something?
Not very much except for the operating system and platforms.

Kind regards
Bernd

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Smoother scrolling w/ deceleration for LC fields

Post by richmond62 » Tue Apr 19, 2022 7:49 pm

Not very much except for the operating system and platforms.
Well, obviously those matter. :(

Post Reply

Return to “Talking LiveCode”