zoomToClientRect

abstract fun zoomToClientRect(rect: Rect, options: TransformRectZoomOptions? = TransformRectZoomOptions(), onSuccess: () -> Unit = {}, onError: (ColibrioException) -> Unit = {})

Applies a transform to the ReaderView that will scale and translate publication content so that the specified rectangle is centered in the ReaderView.

The ReaderView will be scaled as much as possible while still ensuring that the rect is fully visible in the ReaderView. Note also that the ReaderView will never be scaled more than ReaderViewTransformManagerOptions.maxScaleFactor.

You can also specify a maxScaleFactor and configure other parameters for this transform by passing an options object.

Note that the rectangle coordinates refer to the WebView's internal client viewport in CSS pixels. You can receive coordinates in that coordinate system by listening on the various pointer events using ReaderView.addOnMouseEventListener or ReaderView.addOnPointerEventListener. The event object passed to those listeners contains the clientX and clientY properties which can be used with this method.

onSuccess is called when the new active transform has finished animating. onSuccess is called immediately if the transform change is not animated.

onError is called if:

  • canTransform is false.

  • the operation was aborted while animating.

  • The coordinates or scale contained invalid values.

Parameters

rect

The client rect in ReaderView coordinate space defining the area to zoom to.

options

Further configures the transform, including how it is animated.


abstract suspend fun zoomToClientRect(rect: Rect, options: TransformRectZoomOptions? = TransformRectZoomOptions()): ColibrioResult<Unit>

Applies a transform to the ReaderView that will scale and translate publication content so that the specified rectangle is centered in the ReaderView.

The ReaderView will be scaled as much as possible while still ensuring that the rect is fully visible in the ReaderView. Note also that the ReaderView will never be scaled more than ReaderViewTransformManagerOptions.maxScaleFactor.

You can also specify a maxScaleFactor and configure other parameters for this transform by passing an options object.

Note that the rectangle coordinates refer to the WebView's internal client viewport in CSS pixels. You can receive coordinates in that coordinate system by listening on the various pointer events using ReaderView.addOnMouseEventListener or ReaderView.addOnPointerEventListener. The event object passed to those listeners contains the clientX and clientY properties which can be used with this method.

Returns success result when the new active transform has finished animating. Returns immediately if the transform change is not animated.

Returns error result if:

  • canTransform is false.

  • the operation was aborted while animating.

  • The coordinates or scale contained invalid values.

Parameters

rect

The client rect in ReaderView coordinate space defining the area to zoom to.

options

Further configures the transform, including how it is animated.