I have the HorizontalPager with images. If the image has detectTransformGestures, the HorizontalPager will not scroll. If it's not there, then everything works. How can detectTransformGestures be disabled when scrolling horizontally.
var size by remember { mutableStateOf(Size.Zero) }
var scale by remember { mutableStateOf(1f) }
var offset by remember { mutableStateOf(Offset.Zero) }
HorizontalPager(
count = postPictures.size,
modifier = Modifier
.background(Color.Black.copy(alpha = 0.7f))
.fillMaxSize()
.onSizeChanged { size = it.toSize() }
) { image ->
GlideImage(
previewPlaceholder = 0,
imageOptions = ImageOptions(
contentScale = ContentScale.FillWidth
),
requestOptions = { RequestOptions.skipMemoryCacheOf(false) },
modifier = Modifier
.clip(RoundedCornerShape(16.dp))
.pointerInput(Unit) {
detectTransformGestures(
onGesture = { _, pan, zoom, _ ->
val newScale: Float = (scale * zoom).coerceIn(1f, 4f)
val newOffset = offset + pan
scale = newScale
val maxX = (size.width * (scale - 1) / 2f)
val maxY = (size.height * (scale - 1) / 2f)
offset = Offset(
newOffset.x.coerceIn(-maxX, maxX),
newOffset.y.coerceIn(-maxY, maxY)
)
}
)
}
}
.graphicsLayer {
scaleX = scale
scaleY = scale
translationX = offset.x
translationY = offset.y
},
imageModel = postPictures[image],
)