From c37c6fd005549fb47dc7970981691c5a872c09c2 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Fri, 14 Nov 2025 02:11:41 +0800 Subject: [PATCH] Fix story cube animation --- .../Sources/StoryContainerScreen.swift | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift index 1cb2b467c9..b230a3350d 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift @@ -1882,16 +1882,18 @@ private final class StoryContainerScreenComponent: Component { if let previousRotationFraction = itemSetView.rotationFraction, !itemSetTransition.animation.isImmediate { let fromT = previousRotationFraction let toT = panFraction + cubeAdditionalRotationFraction - itemSetTransition.setTransformAsKeyframes(view: itemSetView, transform: { sourceT, isFinal in - let t = fromT * (1.0 - sourceT) + toT * sourceT - if isFinal { - if abs(t - 0.0) <= 0.0001 { - return CATransform3DIdentity + if abs(fromT - toT) > CGFloat.leastNonzeroMagnitude { + itemSetTransition.setTransformAsKeyframes(view: itemSetView, transform: { sourceT, isFinal in + let t = fromT * (1.0 - sourceT) + toT * sourceT + if isFinal { + if abs(t - 0.0) <= 0.0001 { + return CATransform3DIdentity + } } - } - - return calculateCubeTransform(rotationFraction: t, sideAngle: sideAngle, cubeSize: itemFrame.size) - }) + + return calculateCubeTransform(rotationFraction: t, sideAngle: sideAngle, cubeSize: itemFrame.size) + }) + } } else { let updatedTransform: CATransform3D if abs(panFraction + cubeAdditionalRotationFraction) <= 0.0001 {