-
-
Save eevajonnapanula/b92e887c31299df5b4693f786474cd83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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