HeroTransitions / HeroTransitions/Hero

Can Hero use swipe back gesture animation like UINavigationController default swipe back gesture animation in a presenting controller?

Open
#713 0 comments 1 reaction 0 assignees View on GitHub
discussion question
Dominant language
Swift
Stars
22.5k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

First sorry for my bad English.
Here is my code:
`

@objc func hero_setPushAnimationType() {
self.hero.modalAnimationType = .selectBy(presenting: .push(direction: .left), dismissing: .push(direction: .right))
self.hero.isEnabled = true
}

@objc func enableSwipeBackWhenPresent(WithFinishDismissBlock finishDismissBlock: (() -> Void)?) {
self.heroDismissBlock = finishDismissBlock
let gesture = UIScreenEdgePanGestureRecognizer(target: self, action: #selector(swipe(_:)))
gesture.edges = .left
self.view.addGestureRecognizer(gesture)
}

@objc func swipe(_ gesture:UIScreenEdgePanGestureRecognizer) {
switch gesture.state {
case .began:
self.dismiss(animated: true, completion: nil)
case .changed:
let progress = gesture.translation(in: nil).x / self.view.bounds.width
Hero.shared.update(progress)
default:
if (gesture.translation(in: nil).x + gesture.velocity(in: nil).x) / self.view.bounds.width > 0.5 {
self.dismiss(animated: true, completion: nil)
Hero.shared.finish()
if (self.heroDismissBlock != nil) {
self.heroDismissBlock!()
}
} else {
Hero.shared.cancel()
}
}
}
`

Now i can swipe back very similar to UINavigationController, but because of the animation is not linear animation, current controller not tracking while my finger's movement, so how to fix it?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the custom UIScreenEdgePanGestureRecognizer and the calls to Hero.shared.update, finish, and cancel shown in the issue. Investigate how Hero handles interactive dismiss transitions and compare that behavior with UINavigationController's interactive pop gesture. Done means the presenting controller tracks the finger linearly and completes or cancels consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.