Skip to content

Commit

Permalink
updated animation
Browse files Browse the repository at this point in the history
  • Loading branch information
umerjabbar committed May 31, 2023
1 parent dfc3c70 commit 0760001
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions Sources/ContextMenuSwift/ContextMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ open class ContextMenu: NSObject {

let rect = self.viewTargeted.convert(self.mainViewRect.origin, to: nil)
if self.closeAnimation {
UIView.animate(withDuration: 0.3, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 6, options: [.layoutSubviews, .preferredFramesPerSecond60, .allowUserInteraction], animations: {
UIView.animate(withDuration: 0.2, delay: 0, options: [.layoutSubviews, .curveEaseInOut, .allowUserInteraction], animations: {
self.prepareViewsForRemoveFromSuperView(with: rect)
}) { (_) in
DispatchQueue.main.async {
Expand All @@ -390,7 +390,7 @@ open class ContextMenu: NSObject {

let rect = self.viewTargeted.convert(self.mainViewRect.origin, to: nil)
if animation {
UIView.animate(withDuration: 0.3, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 6, options: [.layoutSubviews, .preferredFramesPerSecond60, .allowUserInteraction], animations: {
UIView.animate(withDuration: 0.2, delay: 0, options: [.layoutSubviews, .curveEaseInOut, .allowUserInteraction], animations: {
self.prepareViewsForRemoveFromSuperView(with: rect)
}) { (_) in
DispatchQueue.main.async {
Expand Down Expand Up @@ -641,17 +641,9 @@ open class ContextMenu: NSObject {
self.updateTargetedImageViewRect()

if animated {
UIView.animate(withDuration: 0.2,
delay: 0,
usingSpringWithDamping: 0.9,
initialSpringVelocity: 6,
options: [.layoutSubviews, .preferredFramesPerSecond60, .allowUserInteraction],
animations:
{ [weak self] in

UIView.animate(withDuration: 0.2, delay: 0, options: [.layoutSubviews, .curveEaseInOut, .allowUserInteraction]) { [weak self] in
self?.updateTargetedImageViewPositionFrame()

})
}
} else {
self.updateTargetedImageViewPositionFrame()
}
Expand Down

0 comments on commit 0760001

Please sign in to comment.