Skip to content

Instantly share code, notes, and snippets.

@eevajonnapanula
Created July 11, 2023 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eevajonnapanula/b92e887c31299df5b4693f786474cd83 to your computer and use it in GitHub Desktop.
Save eevajonnapanula/b92e887c31299df5b4693f786474cd83 to your computer and use it in GitHub Desktop.
Box(
Modifier
// Set the source center and styles for the magnifier
.magnifier(
sourceCenter = { magnifierCenter },
zoom = 3f,
style = MagnifierStyle(
size = DpSize(height = 200.dp, width = 300.dp),
),
)
.pointerInput(Unit) {
detectDragGestures(
// Show the magnifier in the initial position
onDragStart = { magnifierCenter = it },
// Magnifier follows the pointer during a drag event
onDrag = { _, delta ->
magnifierCenter = magnifierCenter.plus(delta)
},
// Hide the magnifier when a user ends the drag movement.
onDragEnd = { magnifierCenter = Offset.Unspecified },
onDragCancel = { magnifierCenter = Offset.Unspecified },
)
},
) {
Text(
"Try magnifying this text by dragging a pointer (finger, mouse, other) over the text.",
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment