Skip to content

Commit

Permalink
Small code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
saket committed Dec 10, 2024
1 parent 1274e79 commit 09ac42d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@file:Suppress("NAME_SHADOWING")
@file:OptIn(ExperimentalCoroutinesApi::class)

package me.saket.telephoto.subsamplingimage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ internal class RealZoomableState internal constructor(
}
)

private val gestureStateInputs: GestureStateInputsCalculator by derivedStateOf {
private val gestureStateInputsCalculator: GestureStateInputsCalculator by derivedStateOf {
GestureStateInputsCalculator { viewportSize ->
if (viewportSize.isUnspecifiedOrEmpty || unscaledContentLocation == ZoomableContentLocation.Unspecified) {
return@GestureStateInputsCalculator null
Expand Down Expand Up @@ -191,7 +191,7 @@ internal class RealZoomableState internal constructor(
}

private val currentGestureStateInputs: GestureStateInputs? by derivedStateOf {
gestureStateInputs.calculate(viewportSize)
gestureStateInputsCalculator.calculate(viewportSize)
}

/** See [PlaceholderBoundsProvider]. */
Expand Down Expand Up @@ -344,16 +344,16 @@ internal class RealZoomableState internal constructor(
//
// Note to self: these values are divided by zoom because that's how the final offset
// for UI is calculated: -offset * zoom.
return transformUserOffset { finalOffset ->
return transformUserOffset { currentOffset ->
//
// Move the centroid to the center
// of panned content(?)
// | Scale
// | | Move back
// | | (+ new translation)
// | | |
// ________________|______________ ________|_________ ________|_________
((finalOffset + centroid / oldZoom) - (centroid / newZoom + panDelta / oldZoom)).also {
// | Scale
// | | Move back
// | | (+ new translation)
// | | |
// ________________|_______________ ________|_________ ________|_________
((currentOffset + centroid / oldZoom) - (centroid / newZoom + panDelta / oldZoom)).also {
check(it.isFinite) {
val debugInfo = collectDebugInfoForIssue41(
"centroid" to centroid,
Expand Down

0 comments on commit 09ac42d

Please sign in to comment.