Skip to content

Commit c37c6fd

Browse files
author
Isaac
committed
Fix story cube animation
1 parent cebadbb commit c37c6fd

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,16 +1882,18 @@ private final class StoryContainerScreenComponent: Component {
18821882
if let previousRotationFraction = itemSetView.rotationFraction, !itemSetTransition.animation.isImmediate {
18831883
let fromT = previousRotationFraction
18841884
let toT = panFraction + cubeAdditionalRotationFraction
1885-
itemSetTransition.setTransformAsKeyframes(view: itemSetView, transform: { sourceT, isFinal in
1886-
let t = fromT * (1.0 - sourceT) + toT * sourceT
1887-
if isFinal {
1888-
if abs(t - 0.0) <= 0.0001 {
1889-
return CATransform3DIdentity
1885+
if abs(fromT - toT) > CGFloat.leastNonzeroMagnitude {
1886+
itemSetTransition.setTransformAsKeyframes(view: itemSetView, transform: { sourceT, isFinal in
1887+
let t = fromT * (1.0 - sourceT) + toT * sourceT
1888+
if isFinal {
1889+
if abs(t - 0.0) <= 0.0001 {
1890+
return CATransform3DIdentity
1891+
}
18901892
}
1891-
}
1892-
1893-
return calculateCubeTransform(rotationFraction: t, sideAngle: sideAngle, cubeSize: itemFrame.size)
1894-
})
1893+
1894+
return calculateCubeTransform(rotationFraction: t, sideAngle: sideAngle, cubeSize: itemFrame.size)
1895+
})
1896+
}
18951897
} else {
18961898
let updatedTransform: CATransform3D
18971899
if abs(panFraction + cubeAdditionalRotationFraction) <= 0.0001 {

0 commit comments

Comments
 (0)