diff --git a/pckg/AdvancedContextMenuKit/Sources/AdvancedContextMenuKit/AdvancedContextMenuManager.swift b/pckg/AdvancedContextMenuKit/Sources/AdvancedContextMenuKit/AdvancedContextMenuManager.swift index e1164be2c..0ca2e8529 100644 --- a/pckg/AdvancedContextMenuKit/Sources/AdvancedContextMenuKit/AdvancedContextMenuManager.swift +++ b/pckg/AdvancedContextMenuKit/Sources/AdvancedContextMenuKit/AdvancedContextMenuManager.swift @@ -188,8 +188,17 @@ private extension AdvancedContextMenuManager { } // MARK: Delegate - + extension AdvancedContextMenuManager: OverlayViewDelegate { + func willDissmis() { + guard + let newPosition = getPositionOnScreen?(), + newPosition != locationOnScreen + else { return } + + viewModel?.update(locationOnScreen: newPosition) + } + func didDissmis() { didDismissMenuAction?(messageId) getPositionOnScreen = nil diff --git a/pckg/AdvancedContextMenuKit/Sources/AdvancedContextMenuKit/Implementation/ContextMenuOverlayViewModel.swift b/pckg/AdvancedContextMenuKit/Sources/AdvancedContextMenuKit/Implementation/ContextMenuOverlayViewModel.swift index 815fd1cef..721e2bf6d 100644 --- a/pckg/AdvancedContextMenuKit/Sources/AdvancedContextMenuKit/Implementation/ContextMenuOverlayViewModel.swift +++ b/pckg/AdvancedContextMenuKit/Sources/AdvancedContextMenuKit/Implementation/ContextMenuOverlayViewModel.swift @@ -62,6 +62,8 @@ final class ContextMenuOverlayViewModel: ObservableObject { } @MainActor func dismiss() async { + delegate?.willDissmis() + await animate(duration: animationDuration) { self.additionalMenuVisible.toggle() } diff --git a/pckg/AdvancedContextMenuKit/Sources/AdvancedContextMenuKit/Implementation/OverlayViewDelegate.swift b/pckg/AdvancedContextMenuKit/Sources/AdvancedContextMenuKit/Implementation/OverlayViewDelegate.swift index 4c143ff71..00eb7c087 100644 --- a/pckg/AdvancedContextMenuKit/Sources/AdvancedContextMenuKit/Implementation/OverlayViewDelegate.swift +++ b/pckg/AdvancedContextMenuKit/Sources/AdvancedContextMenuKit/Implementation/OverlayViewDelegate.swift @@ -9,6 +9,7 @@ import Foundation @MainActor protocol OverlayViewDelegate: AnyObject { + func willDissmis() func didDissmis() func didAppear() }