Skip to content

Commit cf1e02e

Browse files
update ZoomModifier coroutine functions
1 parent 8fc483e commit cf1e02e

File tree

1 file changed

+12
-30
lines changed

1 file changed

+12
-30
lines changed

image/src/main/java/com/smarttoolfactory/image/zoom/ZoomModifier.kt

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,10 @@ fun Modifier.zoom(
8686

8787
zoomLevel = newZoomLevel
8888

89-
coroutineScope.launch {
90-
zoomState.animatePanTo(Offset.Zero)
91-
}
92-
93-
coroutineScope.launch {
94-
zoomState.animateZoomTo(newZoom)
95-
}
96-
97-
coroutineScope.launch {
98-
zoomState.animateRotationTo(zoomState.rotationInitial)
89+
coroutineScope.run {
90+
launch { zoomState.animatePanTo(Offset.Zero) }
91+
launch { zoomState.animateZoomTo(newZoom) }
92+
launch { zoomState.animateRotationTo(zoomState.rotationInitial) }
9993
}
10094
}
10195
)
@@ -199,16 +193,10 @@ fun Modifier.zoom(
199193

200194
zoomLevel = newZoomLevel
201195

202-
coroutineScope.launch {
203-
zoomState.animatePanTo(Offset.Zero)
204-
}
205-
206-
coroutineScope.launch {
207-
zoomState.animateZoomTo(newZoom)
208-
}
209-
210-
coroutineScope.launch {
211-
zoomState.animateRotationTo(zoomState.rotationInitial)
196+
coroutineScope.run {
197+
launch { zoomState.animatePanTo(Offset.Zero) }
198+
launch { zoomState.animateZoomTo(newZoom) }
199+
launch { zoomState.animateRotationTo(zoomState.rotationInitial) }
212200
}
213201
}
214202
)
@@ -312,16 +300,10 @@ fun Modifier.zoom(
312300

313301
zoomLevel = newZoomLevel
314302

315-
coroutineScope.launch {
316-
zoomState.animatePanTo(Offset.Zero)
317-
}
318-
319-
coroutineScope.launch {
320-
zoomState.animateZoomTo(newZoom)
321-
}
322-
323-
coroutineScope.launch {
324-
zoomState.animateRotationTo(zoomState.rotationInitial)
303+
coroutineScope.run {
304+
launch { zoomState.animatePanTo(Offset.Zero) }
305+
launch { zoomState.animateZoomTo(newZoom) }
306+
launch { zoomState.animateRotationTo(zoomState.rotationInitial) }
325307
}
326308
}
327309
)

0 commit comments

Comments
 (0)