From 5a29f4680fd0239f657366e005be54d0707ffbe3 Mon Sep 17 00:00:00 2001 From: Dominic Go <18517029+dominicstop@users.noreply.github.com> Date: Sat, 10 Jun 2023 09:04:15 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AB=20Update:=20Exp=20-=20`AdaptiveMod?= =?UTF-8?q?al`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Update experiment/test - `swift-programmatic-modal/AdaptiveModal`. --- .../AdaptiveModal/AdaptiveModalManager.swift | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalManager.swift b/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalManager.swift index c3edccd2..671e0477 100644 --- a/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalManager.swift +++ b/experiments/swift-programmatic-modal/AdaptiveModal/AdaptiveModalManager.swift @@ -1239,18 +1239,26 @@ class AdaptiveModalManager: NSObject { func onModalWillSnap(){ let interpolationSteps = self.interpolationSteps!; - let closestSnapPoint = self.getClosestSnapPoint(); - let prevIndex = self.currentInterpolationIndex; - let nextIndex = closestSnapPoint.interpolationPoint.snapPointIndex; + + let nextIndex: Int = { + guard let nextIndex = self.nextInterpolationIndex else { + let closestSnapPoint = self.getClosestSnapPoint(); + return closestSnapPoint.interpolationPoint.snapPointIndex; + }; + + return nextIndex; + }(); + + let nextPoint = self.interpolationSteps[nextIndex]; guard prevIndex != nextIndex else { return }; self.eventDelegate?.notifyOnModalWillSnap( prevSnapPointIndex: interpolationSteps[prevIndex].snapPointIndex, nextSnapPointIndex: interpolationSteps[nextIndex].snapPointIndex, - snapPointConfig: closestSnapPoint.snapPointConfig, - interpolationPoint: closestSnapPoint.interpolationPoint + snapPointConfig: self.modalConfig.snapPoints[nextPoint.snapPointIndex], + interpolationPoint: nextPoint ); };