Package-level declarations

Types

Link copied to clipboard
class ZoomableGestureScope(var onTap: (Offset) -> Unit = {}, var onDoubleTap: (Offset) -> Unit = {}, var onLongPress: (Offset) -> Unit = {})

ZoomableView手势对象

Link copied to clipboard
open class ZoomableViewState(@FloatRange(from = 1.0) val maxScale: Float = MAX_SCALE_RATE, offsetX: Float = DEFAULT_OFFSET_X, offsetY: Float = DEFAULT_OFFSET_Y, scale: Float = DEFAULT_SCALE, rotation: Float = DEFAULT_ROTATION, animationSpec: AnimationSpec<Float>? = null) : CoroutineScope

viewer状态对象,用于记录compose组件状态

Properties

Link copied to clipboard
const val DEFAULT_OFFSET_X: Float = 0.0f
Link copied to clipboard
const val DEFAULT_OFFSET_Y: Float = 0.0f
Link copied to clipboard
const val DEFAULT_ROTATION: Float = 0.0f
Link copied to clipboard
const val DEFAULT_SCALE: Float = 1.0f
Link copied to clipboard
const val MAX_SCALE_RATE: Float = 4.0f
Link copied to clipboard
Link copied to clipboard
const val MIN_SCALE: Float = 0.5f

Functions

Link copied to clipboard
suspend fun PointerInputScope.detectTransformGestures(panZoomLock: Boolean = false, gestureStart: () -> Unit = {}, gestureEnd: (Boolean) -> Unit = {}, onTap: (Offset) -> Unit = {}, onDoubleTap: (Offset) -> Unit = {}, onGesture: (centroid: Offset, pan: Offset, zoom: Float, rotation: Float, event: PointerEvent) -> Boolean)

重写事件监听方法

Link copied to clipboard
fun getBound(scale: Float, bw: Float, dw: Float): Pair<Float, Float>

获取移动边界

Link copied to clipboard
fun inBound(offset: Float, bound: Pair<Float, Float>): Boolean

判断位移是否在边界内

Link copied to clipboard
fun limitToBound(offset: Float, bound: Pair<Float, Float>): Float

把位移限制在边界内

Link copied to clipboard
fun ZoomableViewState.onGesture(scope: CoroutineScope, center: Offset, pan: Offset, zoom: Float, rotate: Float, event: PointerEvent): Boolean

输入手势事件

Link copied to clipboard
fun ZoomableViewState.onGestureEnd(scope: CoroutineScope, transformOnly: Boolean)

标记手势事件结束

Link copied to clipboard
fun ZoomableViewState.onGestureStart(scope: CoroutineScope)

标记手势事件开始

Link copied to clipboard
fun panTransformAndScale(offset: Float, center: Float, bh: Float, uh: Float, fromScale: Float, toScale: Float): Float

追踪缩放过程中的中心点

Link copied to clipboard
fun rememberZoomableState(contentSize: Size? = null, @FloatRange(from = 1.0) maxScale: Float = MAX_SCALE_RATE, animationSpec: AnimationSpec<Float>? = null): ZoomableViewState

返回一个ZoomableState

Link copied to clipboard

让后一个数与前一个数的符号保持一致

Link copied to clipboard
fun ZoomableView(modifier: Modifier = Modifier, boundClip: Boolean = true, state: ZoomableViewState, detectGesture: ZoomableGestureScope = ZoomableGestureScope(), content: @Composable () -> Unit)

支持对Composable就行手势缩放的组件