Skip to content

Commit c98f669

Browse files
committed
Docs, change notTransformed to transformed
1 parent 074f48c commit c98f669

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

zoomables/src/main/kotlin/de/mr_pine/zoomables/ZoomableImage.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import kotlinx.coroutines.CoroutineScope
2323
* @param contentDescription text for accessibility see [Image] for further info
2424
* @param onSwipeLeft Optional function to run when user swipes from right to left - does nothing by default
2525
* @param onSwipeRight Optional function to run when user swipes from left to right - does nothing by default
26-
* @param dragGestureMode A function with a [ZoomableState] scope that returns a boolean value to enable/disable dragging gestures (swiping and panning). Returns `true` by default. *Note*: For some use cases it may be required that only panning is possible. Use `{!notTransformed}` in that case
26+
* @param dragGestureMode A function with a [ZoomableState] scope that returns a [DragGestureMode] value that signals which drag gesture should currently be active. By default panning is enabled when zoomed, else swipe gestures are enabled.
2727
* @param onDoubleTap Optional function to run when user double taps. Zooms in by 2x when scale is currently 1 and zooms out to scale = 1 when zoomed in when null (default)
2828
*/
2929
@Composable
@@ -60,7 +60,7 @@ public fun ZoomableImage(
6060
* @param contentDescription text for accessibility see [Image] for further info
6161
* @param onSwipeLeft Optional function to run when user swipes from right to left - does nothing by default
6262
* @param onSwipeRight Optional function to run when user swipes from left to right - does nothing by default
63-
* @param dragGestureMode A function with a [ZoomableState] scope that returns a boolean value to enable/disable dragging gestures (swiping and panning). Returns `true` by default. *Note*: For some use cases it may be required that only panning is possible. Use `{!notTransformed}` in that case
63+
* @param dragGestureMode A function with a [ZoomableState] scope that returns a [DragGestureMode] value that signals which drag gesture should currently be active. By default panning is enabled when zoomed, else swipe gestures are enabled.
6464
* @param onDoubleTap Optional function to run when user double taps. Zooms in by 2x when scale is currently 1 and zooms out to scale = 1 when zoomed in when null (default)
6565
*/
6666
@Composable
@@ -101,7 +101,7 @@ public fun ZoomableImage(
101101
* @param contentDescription text for accessibility see [Image] for further info
102102
* @param onSwipeLeft Optional function to run when user swipes from right to left - does nothing by default
103103
* @param onSwipeRight Optional function to run when user swipes from left to right - does nothing by default
104-
* @param dragGestureMode A function with a [ZoomableState] scope that returns a boolean value to enable/disable dragging gestures (swiping and panning). Returns `true` by default. *Note*: For some use cases it may be required that only panning is possible. Use `{!notTransformed}` in that case
104+
* @param dragGestureMode A function with a [ZoomableState] scope that returns a [DragGestureMode] value that signals which drag gesture should currently be active. By default panning is enabled when zoomed, else swipe gestures are enabled.
105105
* @param onDoubleTap Optional function to run when user double taps. Zooms in by 2x when scale is currently 1 and zooms out to scale = 1 when zoomed in when null (default)
106106
*/
107107
@Composable

zoomables/src/main/kotlin/de/mr_pine/zoomables/ZoomableState.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ private const val zoomedThreshold = 1.0E-3f
2323
* An implementation of [TransformableState] containing the values for the current [scale], [offset] and [rotation]. It's normally obtained using [rememberTransformableState]
2424
* Other than [TransformableState] obtained by [rememberTransformableState], [ZoomableState] exposes [scale], [offset] and [rotation]
2525
*
26+
* As
27+
*
2628
* @param scale [MutableState]<[Float]> of the scale this state is initialized with
2729
* @param offset [MutableState]<[Offset]> of the offset this state is initialized with
2830
* @param rotation [MutableState]<[Float]> in degrees of the rotation this state is initialized with
@@ -34,7 +36,8 @@ private const val zoomedThreshold = 1.0E-3f
3436
* @property scale The current scale as [MutableState]<[Float]>
3537
* @property offset The current offset as [MutableState]<[Offset]>
3638
* @property rotation The current rotation in degrees as [MutableState]<[Float]>
37-
* @property notTransformed `true` if [scale] is `1`, [offset] is [Offset.Zero] and [rotation] is `0`
39+
* @property transformed `false` if [scale] is `1`, [offset] is [Offset.Zero] and [rotation] is `0`
40+
* @property zoomed Whether the content is zoomed (in or out)
3841
*/
3942
public class ZoomableState(
4043
public var scale: MutableState<Float>,
@@ -47,10 +50,8 @@ public class ZoomableState(
4750
public val zoomed: Boolean
4851
get() = scale.value in (1 - zoomedThreshold)..(1 + zoomedThreshold)
4952

50-
public val notTransformed: Boolean
51-
get() {
52-
return zoomed && offset.value.getDistanceSquared() in -1.0E-6f..1.0E-6f && rotation.value in -1.0E-3f..1.0E-3f
53-
}
53+
public val transformed: Boolean
54+
get() = zoomed || offset.value.getDistanceSquared() !in -1.0E-6f..1.0E-6f || rotation.value !in -1.0E-3f..1.0E-3f
5455

5556
private val transformScope: TransformScope = object : TransformScope {
5657
override fun transformBy(zoomChange: Float, panChange: Offset, rotationChange: Float) =

zoomables/src/main/kotlin/de/mr_pine/zoomables/Zoomables.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import kotlin.math.*
3737
*
3838
* @param coroutineScope used for smooth asynchronous zoom/pan/rotation animations
3939
* @param zoomableState Contains the current transform states - obtained via [rememberZoomableState]
40-
* @param dragGestureMode A function with a [ZoomableState] scope that returns a boolean value to enable/disable dragging gestures (swiping and panning). Returns `true` by default. *Note*: For some use cases it may be required that only panning is possible. Use `{!notTransformed}` in that case
40+
* @param dragGestureMode A function with a [ZoomableState] scope that returns a [DragGestureMode] value that signals which drag gesture should currently be active. By default panning is enabled when zoomed, else swipe gestures are enabled.
4141
* @param onSwipeLeft Optional function to run when user swipes from right to left - does nothing by default
4242
* @param onSwipeRight Optional function to run when user swipes from left to right - does nothing by default
4343
* @param minimumSwipeDistance Minimum distance the user has to travel on the screen for it to count as swiping

0 commit comments

Comments
 (0)