Closed hellosagar closed 1 month ago
Currently, on passing the same offset, it behaves like the following.
zoomState.changeScale(
zoomState.scale + 1,
Offset(zoomState.offsetX, zoomState.offsetY),
)
Removed the media
@usuiat I would appreciate your response. Thanks!
@hellosagar
One possible way to achieve this is Modifier.onSizeChanged
.
You can get the size of image like below.
var size = remember { Size.Unspecified }
Image(
...
modifier = Modifier
.onSizeChanged { size = it.toSize() }
.zoomable( ... )
)
Then you can pass size.center
to ZoomState.changeScale
.
zoomState.changeScale(
targetScale = 2f,
position = size.center
)
By the way, I am wondering if I should make ZoomState.layoutSize
public.
Because it is not available at the time ZoomState
is created.
Thanks that helped! It would be nice to make the zoomState.layoutSize
as it's already available inside the zoomState, eliminating the need to keep a separate state of the size.
I've take a look at this PR. According to this I can use
Where X and Y would be if I understood it correctly. @usuiat Is the formula looks correct to you?
Currently cant access the layout size from the
zoomState
. How can I achieve this?