Browse Source
This is related to issue: https://github.com/JetBrains/compose-multiplatform/issues/4258 changes - DesktopSplitPane.kt: placable.place() -> placable.placeRelative - SplitePaneDSL.kt: change the delta direction to follow the layout direction ```kotlin @Composable override fun Modifier.markAsHandle(): Modifier = this.run { val layoutDirection = LocalLayoutDirection.current pointerInput(containerScope.splitPaneState) { detectDragGestures { change, _ -> change.consume() containerScope.splitPaneState.dispatchRawMovement( if (containerScope.isHorizontal) if (layoutDirection == LayoutDirection.Ltr) change.position.x else -change.position.x else change.position.y ) } } ``` the problem with .onPointerEvent() Modifier, or onDrag also, is whenever the layout direction is Ltr or Rtl: moving to right always produce positive change, [expected negative if dir =Rtl] moving to left always produce negative change, [expected positive if dir =Rtl] the calculation of postion will fail if layoutDir is Rtl, because positionPercentage will be out of range ```kotlin fun dispatchRawMovement(delta: Float) { val movableArea = maxPosition - minPosition if (movableArea > 0) { positionPercentage = ((movableArea * positionPercentage) + delta).coerceIn(0f, movableArea) / movableArea } } ```pull/4269/head
Ahmed Hosny
11 months ago
committed by
GitHub
3 changed files with 34 additions and 19 deletions
Loading…
Reference in new issue