A scrolling primer

A few years ago, I wrote a post about scrolling in GTK+ 3. Time for another look!

The common case

The basic idea of the changes described back then is still the same. We expect touchpad (or track point) scrolling to be one of the most common forms of scrolling, and the scrollbar operates as a narrow indicator for this.

As you can see, we change the cursor to indicate scrolling, and it you can freely scroll in all directions. It is kinetic, too.

Classical scrolling

Of course, it is still possible to just click and drag the slider, for classical scrolling.

Another aspect of ‘classical’ scrolling is that you can click on the trough outside the slider, and either warp the position to where you clicked, or jump in page-size increments.

By default, a primary click warps, and Shift-primary click goes by pages. We just added back middle click as an alternative to Shift-primary click, since this is a common alternative that many people are used to. For mainly historical reasons, GTK+ has a setting, gtk-primary-button-warps-slider, which switches the roles of primary click and Shift-primary click for this.

The typical keyboard shortcuts (Page Up, Page Down, Home, End) let you control scrolling with the keyboard.

Smooth scrolling

There’s more to scrolling in GTK+ that you may not know about. One feature that we introduced long ago is a ‘zoom’ or ‘fine adjustment’ mode, which slows the scrolling down to allow pixel-precise positioning.

To trigger this mode you can either use a long press or shift-click in the slider. As you can see in the video, once you move the pointer below or above the scrollbar, it will keep scrolling at the same relaxed speed until you let go.

As a variation on this theme, more recently we added a variable speed variant of smooth scrolling.

To trigger it, you secondary click in the trough outside the slider. Once the scrolling starts, you can control the speed by moving the pointer closer or farther away from the scrollbar. This is pretty addictive, once you’ve discovered it!

Custom locations

As the last feature, applications can add a context menu that gets triggered by secondary click on the slider, and make it scroll to important positions.

Thats it, scroll on!

7 thoughts on “A scrolling primer”

  1. Thanks. Didn’t knew the variable speed smooth scrolling.
    Works fine in Nautilus, but (as usual) not in the WebView of WebKit2 and I tried it several times in Epiphany, until I figured out that this was always problematic.

  2. > As you can see in the video, once you move the pointer below or above the scrollbar, it will keep scrolling at the same relaxed speed until you let go.

    This does not work for me at all. When I stop moving the mouse in “slow scroll” mode, it stops the scrolling, no matter where my mouse is.

    Is this a bug? I’m running gtk3-3.22.21-1.fc26.x86_64 (Fedora 26) and I can reproduce this with most gtk3 applications including nautilus and gtk3-demo.

  3. Chris: same here on 3.22.24, Debian unstable, x11.

    I wonder if it’s to do with the recent changes around grabs on ranges.

  4. Maybe a bit offtopic, but since GTK supports kinetic scrolling why GNOME WEB doesnt have that? Because in reality kinetic scrolling is mostly useful when scrolling on the web pages.

Leave a Reply

Your email address will not be published. Required fields are marked *