Skip to content

Commit e36419c

Browse files
update README.md
Add documentation about AnimatedZoomModifier and AnimatedZoomLayout
1 parent d8ae066 commit e36419c

File tree

1 file changed

+67
-12
lines changed

1 file changed

+67
-12
lines changed

README.md

Lines changed: 67 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
[![](https://jitpack.io/v/SmartToolFactory/Compose-Image.svg)](https://jitpack.io/#SmartToolFactory/Compose-Image)
44

5-
6-
75
Collection of Images, Modifiers, utility functions for Jetpack Compose to expand
86
and enrich displaying, manipulating, scaling, resizing, zooming, and
97
getting cropped `ImageBitmap` based on selection area, before/after image to with handle to
@@ -13,7 +11,6 @@ https://user-images.githubusercontent.com/35650605/179715223-ba681886-6032-461f-
1311

1412
https://user-images.githubusercontent.com/35650605/185785993-58aee8fb-8f27-4664-9ebe-5cde04b5a04e.mp4
1513

16-
1714
## Gradle Setup
1815

1916
To get a Git project into your build:
@@ -221,10 +218,6 @@ fun MorphLayout(
221218

222219
## Zoom
223220

224-
225-
226-
227-
228221
Zoom feature provides zooming in or out Image, or Composables with animations and
229222
getting data about current transform or image Using Callbacks.
230223

@@ -398,7 +391,7 @@ fun Modifier.enhancedZoom(
398391
developer to define zoom on double tap gesture
399392
* **enabled** lambda can be used selectively enable or disable pan and intercepting with scroll,
400393
drag or lists or pagers using current zoom, pan or rotation values
401-
* **onGestureStart callback to to notify gesture has started and return current [EnhancedZoomData]
394+
* **onGestureStart** callback to to notify gesture has started and return current [EnhancedZoomData]
402395
of this modifier
403396
* **onGesture** callback to notify about ongoing gesture and return current [EnhancedZoomData] of
404397
this modifier
@@ -433,7 +426,7 @@ fun Modifier.enhancedZoom(
433426

434427
* **initialZoom** zoom set initially
435428
* **minZoom** minimum zoom value
436-
* **maxZoom maximum zoom value
429+
* **maxZoom** maximum zoom value
437430
* **fling** when set to true dragging pointer builds up velocity. When last pointer leaves
438431
Composable a movement invoked against friction till velocity drops below to threshold
439432
* **moveToBounds** when set to true if image zoom is lower than initial zoom or panned out of image
@@ -455,7 +448,7 @@ is up but continues motion agains friction.
455448
`moveToBound` is true image moves to bounds when moved out of bounds. When
456449
`fling` is set to true image moves until velocity drops below threshold.
457450

458-
```
451+
```kotlin
459452
@Composable
460453
fun EnhancedZoomableImage(
461454
modifier: Modifier = Modifier,
@@ -520,10 +513,10 @@ bounds with an animation or option to have fling gesture when user removes from
520513
velocity is higher than threshold to have smooth touch effect.
521514

522515
Difference between `Modifier.enhancedZoom()` and `Modifier.animatedZoom()` is enhanced zoom
523-
uses Bitmap dimensions and returns a callback that returns [EnhandedZoomData] that contains
516+
uses Bitmap dimensions and returns a callback that returns [EnhancedZoomData] that contains
524517
visible image area which is suitable for crop while `Modifier.animatedZoom()` requires
525518
dimensions of Composable to have valid pan limiting behavior. More suitable for zooming
526-
Composables while enhanced zoom is more suitable for iamge zooming.
519+
Composables while enhanced zoom is more suitable for image zooming.
527520

528521
```kotlin
529522
fun Modifier.animatedZoom(
@@ -554,6 +547,23 @@ configuration to allow changing pan, zoom, and rotation.
554547
Allows to change zoom, pan, translate, or get current state by calling methods on this object. To be
555548
hosted and passed to [Modifier.animatedZoom].
556549

550+
```kotlin
551+
@Composable
552+
fun rememberAnimatedZoomState(
553+
contentSize: DpSize = DpSize.Zero,
554+
initialZoom: Float = 1f,
555+
minZoom: Float = 1f,
556+
maxZoom: Float = 5f,
557+
fling: Boolean = true,
558+
moveToBounds: Boolean = false,
559+
zoomable: Boolean = true,
560+
pannable: Boolean = true,
561+
rotatable: Boolean = false,
562+
limitPan: Boolean = true,
563+
key1: Any? = Unit
564+
)
565+
```
566+
557567
#### Parameters
558568

559569
* **contentSize** when the content that will be zoomed is not parent pass child size to bound
@@ -571,3 +581,48 @@ hosted and passed to [Modifier.animatedZoom].
571581
* **rotatable** when set to true rotation is enabled
572582
* **limitPan** limits pan to bounds of parent Composable. Using this flag prevents creating empty
573583
space on sides or edges of parent
584+
585+
### AnimatedZoomLayout
586+
587+
Layout that can zoom, rotate, pan its content with fling and moving back to bounds animation.
588+
589+
```kotlin
590+
@Composable
591+
fun AnimatedZoomLayout(
592+
modifier: Modifier = Modifier,
593+
clip: Boolean = true,
594+
initialZoom: Float = 1f,
595+
minZoom: Float = 1f,
596+
maxZoom: Float = 3f,
597+
fling: Boolean = true,
598+
moveToBounds: Boolean = false,
599+
zoomable: Boolean = true,
600+
pannable: Boolean = true,
601+
rotatable: Boolean = false,
602+
limitPan: Boolean = true,
603+
enabled: (Float, Offset, Float) -> Boolean = DefaultEnabled,
604+
zoomOnDoubleTap: (ZoomLevel) -> Float = DefaultOnDoubleTap,
605+
content: @Composable () -> Unit
606+
)
607+
```
608+
609+
#### Parameters
610+
611+
* **clip** when set to true clips to parent bounds. Anything outside parent bounds is not
612+
* drawn
613+
* **minZoom** minimum zoom value
614+
* **maxZoom** maximum zoom value
615+
* **fling** when set to true dragging pointer builds up velocity. When last pointer leaves
616+
Composable a movement invoked against friction till velocity drops below to threshold
617+
* **moveToBounds** when set to true if image zoom is lower than initial zoom or panned out of image
618+
boundaries moves back to bounds with animation.
619+
* **zoomable** when set to true zoom is enabled
620+
* **pannable** when set to true pan is enabled
621+
* **rotatable** when set to true rotation is enabled
622+
* **limitPan** limits pan to bounds of parent Composable. Using this flag prevents creating empty
623+
space on sides or edges of parent
624+
* **zoomOnDoubleTap** lambda that returns current [ZoomLevel] and based on current level enables
625+
developer to define zoom on double tap gesture
626+
* **enabled** lambda can be used selectively enable or disable pan and intercepting with scroll,
627+
drag or lists or pagers using current zoom, pan or rotation values
628+

0 commit comments

Comments
 (0)