https://kotlinlang.org logo
Title
t

TheMrCodes

02/15/2021, 1:45 PM
If I scroll through a LazyColumn by emulating Touch (Drag-n-Drop) the scrolling studders and the fling animation is not visible. Is this intended behavior on Desktop or a bug? (Behaivior shown in video in the Thread)
Source code:
@Composable
fun MainContent() {
    val data = (0 until 1000).map { "Item $it" }
    LazyColumn(Modifier.fillMaxSize()) {
        items(data) { text ->
            Text(
                text,
                Modifier
                    .clickable { println("Element $text clicked!") }
                    .padding(14.dp)
                    .fillMaxWidth()
            )
        }
    }
}
c

Cyril Find

02/15/2021, 1:49 PM
not sure but you can try using
remember
on
data
because maybe doing a thousands times the
map
operation on each compose is impacting performance ?
t

TheMrCodes

02/15/2021, 1:52 PM
No nothing changed when wrapping
data
into a remember or collect it to a List (
.toList()
)
😕 1
i

Igor Demin

02/15/2021, 1:52 PM
How do you emulate touch? All scrollable components (including LazyColumn) only work (for now) with mouse-wheel-scroll events on desktop (touchpads on notebooks are also produce mouse-wheel events). Scrollable components shouldn't react on mouse drag/move.
t

TheMrCodes

02/15/2021, 1:54 PM
I tested it with my Microsoft Surface touchscreen and by drag with a normal PC mouse and both time it scrolls but dosn't display the velocity updates
i

Igor Demin

02/15/2021, 2:02 PM
Oh, there is a bug in build150/build152. Will be fixed in the tomorrow release. We accidentally enable scrolling by mouse drag (we should scroll only by "touch" drag, true touch drag isn't supported on desktop yet). How will build149 work on Microsoft Surface?
t

Timo Drick

02/15/2021, 2:06 PM
Why do you not want to support mouse drag? And also it would be nice to have smooth scralling like in IntelliJ. I think it emulates smooth scrolling by animating from one step to the next step.
t

TheMrCodes

02/15/2021, 2:08 PM
@Igor Demin was running on 0.3.0-build152 just tested build149 and touch is not working at all for scrolling
@Timo Drick there are some notes in the source code of compose that suggests that the diffrent pointer types (like mouse, touch, etc.) aren't fully implemented yet
👍 1
i

Igor Demin

02/15/2021, 2:18 PM
Why do you not want to support mouse drag
We support mouse drag, just not for scrollable components. Scrollable components reacting to mouse drag look strange on desktop.
I think it emulates smooth scrolling by animating from one step to the next step.
Yes, we want to implement smooth scrolling, but it is not in our priority.
just tested build149 and touch is not working at all for scrolling
So Microsoft Surface doesn't emulate scroll events 🤔. Good to know, thanks! True touch support isn't in our priority too, but we will eventually support this.
:thank-you: 2
t

TheMrCodes

02/16/2021, 5:48 PM
Update: Build 153 fixes the problem as described + scrolling on the Surface's touchscreen doesn't work anymore (as expacted)