Skip to content

Commit

Permalink
doc: Add a recipe for setting zoom limits
Browse files Browse the repository at this point in the history
  • Loading branch information
saket committed Nov 23, 2023
1 parent ed4802f commit fe91eee
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion docs/zoomableimage/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,39 @@
- [Observing pan & zoom](../zoomable/recipes.md#observing-pan-zoom)
- [Resetting zoom](../zoomable/recipes.md#resetting-zoom)

### Setting zoom limits

=== "Coil"
```kotlin hl_lines="2"
val zoomableState = rememberZoomableState(
zoomSpec = ZoomSpec(maxZoomFactor = 4f)
)

ZoomableAsyncImage(
state = rememberZoomableImageState(zoomableState),
model = "https://example.com/image.jpg",
contentDescription = …,
)
```
=== "Glide"
```kotlin hl_lines="2"
val zoomableState = rememberZoomableState(
zoomSpec = ZoomSpec(maxZoomFactor = 4f)
)

ZoomableGlideImage(
state = rememberZoomableImageState(zoomableState),
model = "https://example.com/image.jpg",
contentDescription = …,
)
```

### Observing image loads

```kotlin
val imageState = rememberZoomableImageState()

// Whether the full quality image is loaded. This be false for placeholders
// Whether the full quality image is loaded. This will be false for placeholders
// or thumbnails, in which case isPlaceholderDisplayed can be used instead.
val showLoadingIndicator = imageState.isImageDisplayed

Expand Down

0 comments on commit fe91eee

Please sign in to comment.