Skip to content

Commit

Permalink
Fix tick interpolation happening when it shouldn't (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeDiamondPro authored Feb 7, 2024
1 parent f587062 commit 4955791
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/main/kotlin/dev/isxander/zoomify/zoom/ZoomHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class ZoomHelper(

val targetZoom = if (zooming) 1.0 else 0.0
prevInitialInterpolation = initialInterpolation
initialInterpolation = initialInterpolator.tickInterpolation(targetZoom, initialInterpolation, lastFrameDuration)
initialInterpolation =
initialInterpolator.tickInterpolation(targetZoom, initialInterpolation, lastFrameDuration)
prevInitialInterpolation = initialInterpolator.modifyPrevInterpolation(prevInitialInterpolation)
if (!initialInterpolator.isSmooth)
prevInitialInterpolation = initialInterpolation
Expand Down Expand Up @@ -77,15 +78,28 @@ class ZoomHelper(

private fun getInitialZoomMultiplier(tickDelta: Float): Double {
return Mth.lerp(
initialInterpolator.modifyInterpolation(Mth.lerp(tickDelta.toDouble(), prevInitialInterpolation, initialInterpolation)),
if (initialInterpolator.isSmooth) initialInterpolator.modifyInterpolation(
Mth.lerp(
tickDelta.toDouble(),
prevInitialInterpolation,
initialInterpolation
)
) else initialInterpolation,
1.0,
if (!resetting) 1 / initialZoom().toDouble() else resetMultiplier
)
}

private fun getScrollZoomDivisor(tickDelta: Float): Double {
return Mth.lerp(
scrollInterpolator.modifyInterpolation(Mth.lerp(tickDelta.toDouble(), prevScrollInterpolation, scrollInterpolation)),
if (scrollInterpolator.isSmooth) scrollInterpolator.modifyInterpolation(
Mth.lerp(
tickDelta.toDouble(),
prevScrollInterpolation,
scrollInterpolation
)
)
else scrollInterpolation,
0.0,
Zoomify.maxScrollTiers * (scrollZoomAmount() * 3.0)
).let { if (resetting) 0.0 else it }
Expand Down

0 comments on commit 4955791

Please sign in to comment.