Skip to content

Add possibility to change dynamically between different scroll simulations depending of the platform - #13396

Draft
Murmele wants to merge 27 commits into
slint-ui:masterfrom
Murmele:mm/flickable-scroll-animation-v2
Draft

Murmele wants to merge 27 commits into
slint-ui:masterfrom
Murmele:mm/flickable-scroll-animation-v2

Conversation

@Murmele

@Murmele Murmele commented Sep 14, 2026

Copy link
Copy Markdown
Member

API

The flickable gets three new properties, carry-momentum and bounce.
bounce is used to simulate ios behavior going out of limit and returning with a spring damper system to the limit when releasing the finger / mouse button
carry-momentum is used to control whether the velocity of the current running animation shall be readded to the newly estimated velocity (ios imitation) or if it shall be ignored

export component TestCase inherits Window {
    width: 500phx;
    height: 500phx;

    fli := Flickable {
        carry-momentum: off; // auto, on, off
        bounce: off; // auto, on, off
    }
}

Currently the enum is called AutoBool with the properties auto, on, off. Auto can be interpreted generically. For the flickable it is used to enable bouncing automatically for specific platforms like ios/macos and disabling it for all other platforms

  • Discussion about the AutoBool enum name
  • Sometimes the velocity tracker estimates a positive velocity even when scrolling down

… different animations depending on the used platform
@Murmele
Murmele force-pushed the mm/flickable-scroll-animation-v2 branch from bcf1c38 to 74bb938 Compare September 15, 2026 08:34
@Murmele

Murmele commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

Negative is ok, Positive is not (See last events)

16245 16278 I RustStdoutStderr: RB: GeneralVelocityTracker { buffer: VelocityRingBuffer: [(Instant(16176), (0.6666565, -17.333313)),(Instant(16192), (0.3333435, -78.333374)),(Instant(16208), (10.0, -146.99997)),(Instant(16225), (38.33333, -222.00002)),(Instant(16233), (0.0, -1.3333282)),] }
16245 16278 I RustStdoutStderr: Setup new animation with velocity: -11022.191
16245 16278 I RustStdoutStderr: RB: GeneralVelocityTracker { buffer: VelocityRingBuffer: [(Instant(16844), (1.6666565, -31.666656)),(Instant(16861), (15.0, -109.33334)),(Instant(16876), (52.000015, -219.33333)),(Instant(16888), (0.333313, -1.3333435)),] }
16245 16278 I RustStdoutStderr: Setup new animation with velocity: -5741.407
16245 16278 I RustStdoutStderr: RB: GeneralVelocityTracker { buffer: VelocityRingBuffer: [(Instant(17312), (0.0, -18.333344)),(Instant(17327), (-0.66667175, -78.0)),(Instant(17345), (17.000015, -136.0)),(Instant(17360), (52.0, -197.33331)),(Instant(17371), (0.333313, -1.0)),] }
16245 16278 I RustStdoutStderr: Setup new animation with velocity: -8231.488
16245 16278 I RustStdoutStderr: RB: GeneralVelocityTracker { buffer: VelocityRingBuffer: [(Instant(18362), (1.0, -30.0)),(Instant(18381), (2.3333282, -127.66669)),(Instant(18395), (28.333328, -180.0)),(Instant(18410), (28.333344, -146.0)),] }
16245 16278 I RustStdoutStderr: Setup new animation with velocity: -12526.66
16245 16278 I RustStdoutStderr: RB: GeneralVelocityTracker { buffer: VelocityRingBuffer: [(Instant(19163), (-2.6666718, -22.666626)),(Instant(19179), (-2.6666718, -84.66669)),(Instant(19196), (14.3333435, -140.66666)),(Instant(19213), (50.66667, -175.66667)),(Instant(19224), (40.666656, -118.00001)),] }
16245 16278 I RustStdoutStderr: Setup new animation with velocity: -12395.169
16245 16278 I RustStdoutStderr: RB: GeneralVelocityTracker { buffer: VelocityRingBuffer: [(Instant(19880), (-4.6666565, -68.66669)),(Instant(19897), (5.0, -132.0)),(Instant(19914), (34.66667, -220.66667)),(Instant(19923), (0.0, -1.3333282)),] }
16245 16278 I RustStdoutStderr: Setup new animation with velocity: -7131.483
16245 16245 D ActivityThread: Package [com.google.android.projection.gearhead] reported as REPLACED, but missing application info. Assuming REMOVED.
16245 16245 D ActivityThread: Package [com.google.android.projection.gearhead] reported as REPLACED, but missing application info. Assuming REMOVED.
16245 16245 D ActivityThread: Package [com.google.android.projection.gearhead] reported as REPLACED, but missing application info. Assuming REMOVED.
16245 16278 I RustStdoutStderr: RB: GeneralVelocityTracker { buffer: VelocityRingBuffer: [(Instant(25255), (-3.0, 12.666672)),(Instant(25272), (-13.0, 59.66667)),(Instant(25287), (-12.666672, 124.999985)),(Instant(25299), (-7.6666718, 116.33334)),] }
16245 16278 I RustStdoutStderr: Setup new animation with velocity: 11826.802
16245 16278 I RustStdoutStderr: RB: GeneralVelocityTracker { buffer: VelocityRingBuffer: [(Instant(25974), (-4.6666565, 30.0)),(Instant(25991), (3.0, 120.33331)),(Instant(26000), (9.333328, 139.66666)),] }
16245 16278 I RustStdoutStderr: Setup new animation with velocity: 18440.113
16245 16278 I RustStdoutStderr: RB: GeneralVelocityTracker { buffer: VelocityRingBuffer: [(Instant(27090), (-6.0, 77.33331)),(Instant(27108), (9.666672, 202.00003)),(Instant(27109), (0.0, 1.333313)),] }
16245 16278 I RustStdoutStderr: Setup new animation with velocity: 812.8564
16245 16278 I RustStdoutStderr: RB: GeneralVelocityTracker { buffer: VelocityRingBuffer: [(Instant(76780), (3.0, -12.6666565)),(Instant(76796), (2.6666565, -10.0)),(Instant(76813), (1.6666565, -6.6666718)),(Instant(76830), (1.666687, -5.6666718)),(Instant(76846), (1.0, -3.0)),(Instant(76863), (0.6666565, -2.0)),(Instant(76880), (0.3333435, -0.6666565)),(Instant(76896), (0.6666565, -0.3333435)),(Instant(76913), (0.0, -0.33332825)),(Instant(76930), (0.3333435, 0.0)),(Instant(76948), (0.0, 0.0)),(Instant(76963), (0.0, 0.0)),(Instant(76980), (0.0, 0.0)),(Instant(77030), (0.0, -0.33332825)),(Instant(77047), (0.0, 0.0)),(Instant(77082), (-0.3333435, -0.3333435)),(Instant(77114), (-0.3333435, -0.33332825)),(Instant(77130), (0.0, 0.0)),(Instant(77164), (0.0, -0.33332825)),(Instant(77215), (0.0, -0.3333435)),] }
16245 16278 I RustStdoutStderr: RB: GeneralVelocityTracker { buffer: VelocityRingBuffer: [(Instant(80203), (5.3333435, -11.666626)),(Instant(80218), (4.6666565, -11.333374)),(Instant(80233), (8.0, -21.666656)),(Instant(80251), (8.3333435, -27.0)),(Instant(80268), (9.0, -27.0)),(Instant(80280), (0.0, 0.0)),] }
16245 16278 I RustStdoutStderr: Setup new animation with velocity: -1145.8597
  • bounce is on
  • carry-momentum is on
import { ListView } from "std-widgets.slint";
export component MainWindow inherits Window {
    preferred-width: 300px;
    preferred-height: 300px;

    in-out property <string> result;
    callback clicked(int);
    in-out property <length> content-y <=> lv.content-y;

    property <[color]> row-colors: [
        #e6194b, #3cb44b, #ffe119, #4363d8, #f58231,
        #911eb4, #46f0f0, #f032e6, #bcf60c, #fabebe,
    ];

    lv := Flickable {
        bounce: AutoBool.on;
        carry-momentum: AutoBool.on;
        VerticalLayout {
            for _[num] in 213: HorizontalLayout {
                if true: Rectangle {
                    height: 200px;
                    border-width: 1px;
                    border-color: red;
                    background: root.row-colors[Math.mod(num, 10)];
                    Text { text: num; }
                    TouchArea {
                        clicked => { result = "|"+num; root.clicked(num) }
                    }
                }
            }
        }
    }
}

When touching again, difference of the points decreases extremely before the next move
rb_plot_combined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant