Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ All notable changes to this project will be documented in this file. Take a look

* Fixed turning pages of an EPUB reflowable resource with an odd number of columns. A virtual blank trailing column is appended to the resource when displayed as two columns.
* EPUB: Fallback on `reflowable` if the `presentation.layout` hint is missing from a manifest.
* EPUB: Offset of the current selection's `rect` to take into account the vertical padding.


## [2.1.1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,18 +366,33 @@ class EpubNavigatorFragment private constructor(
?.let { tryOrLog { JSONObject(it) } }
?: return null

val rect = json.optRectF("rect")
?.apply { adjustToViewport() }

return Selection(
locator = currentLocator.value.copy(
text = Locator.Text.fromJSON(json.optJSONObject("text"))
),
rect = json.optRectF("rect")
rect = rect
)
}

override fun clearSelection() {
run(viewModel.clearSelection())
}

private fun PointF.adjustToViewport() {
currentFragment?.paddingTop?.let { top ->
y += top
}
}

private fun RectF.adjustToViewport() {
currentFragment?.paddingTop?.let { top ->
this.top += top
}
}

// DecorableNavigator

override fun <T : Decoration.Style> supportsDecorationStyle(style: KClass<T>): Boolean =
Expand Down Expand Up @@ -452,14 +467,13 @@ class EpubNavigatorFragment private constructor(
}

override fun onTap(point: PointF): Boolean {
point.adjustToViewport()
return listener?.onTap(point) ?: false
}

override fun onDecorationActivated(id: DecorationId, group: String, rect: RectF, point: PointF): Boolean {
currentFragment?.paddingTop?.let { top ->
rect.top += top
point.y += top
}
rect.adjustToViewport()
point.adjustToViewport()
return viewModel.onDecorationActivated(id, group, rect, point)
}

Expand Down