herotransitions / hero Goto Github PK
View Code? Open in Web Editor NEWElegant transition library for iOS & tvOS
Home Page: https://HeroTransitions.github.io/Hero/
License: MIT License
Elegant transition library for iOS & tvOS
Home Page: https://HeroTransitions.github.io/Hero/
License: MIT License
After installing the pod file when I try to import Hero I'm getting a No such module Hero error. Why is it so? Can you help me on this?
Hi, great library!
I face an issue, is there a possible reason why I cant set the HeroId for an UIImageView? Checked the code and the extension is set to UIView, so I don't see any obvious reason why the UIImageView doesn't use the Hero extension...
Any help appreciated
Edit: The UIImageView I'm using is a custom subclass with a bunch (lots) of IBInspectable, it seems to me like XCode can only display a certain amount of Inspectables and drops the others ...
Is there any plan to add push segues support?
When I navigate via an Unwind Segue my Hero-based transition doesn't work. Instead of abiding by the "Source()" modifier I set in the storyboard, it just uses the default vertical sliding transition animation. However, it works perfectly for other segues, just not Unwind segues. Does anybody know how to fix this issue?
I run the demo,result in " Xcode a declaration cannot be both 'final' and 'dynamic' "
I search on stackoverflow,find out that do not let static class property in extension class. Is there any solution?
What I ran into was pulling your ImageGallery example code into my project as a baseline for modification to my needs.
What I immediately ran into was in ImageViewController.swift on line 67
ImageGallery/ImageViewController.swift:67:38: Binary operator '+' cannot be applied to two 'CGPoint' operands.
This is declared internal in CG+Hero.swift on line 76. Since I am pulling this in as a pod while the example code is just an internal library I get the error and it doesn't.
I had to change the CG+Hero.swift to public to get that code to compile in my project. Should all the overloads just be made public? I am just starting to use this maybe there is a reason not to do that. I would rather use pods than copy it locally if possible.
Thanks and this library really looks like it's going to be very useful.
Please, could you add apple tv support
I think the API would be far clearer and easy to use if heroModifers
wasn't a string. The benefits of a non "stringly-typed" API are pretty clear, but to outline a few:
I would love to take on this task, but I wanted to ask which of two directions I should go, and if you might merge a PR like this before I start working on it.
Introduce a new Enum with associated values for each Modifier - something like
enum Modifier {
case scale(CGFloat)
case fade
case ...
}
Views would retain the heroModifiers
property, but it would become an array of Modifier
, used like this: foo.heroModifiers = [.fade, .scale(0.5)]
.
This design is nice because an enum encapsulates the possible modifiers well, especially with associated values. One drawback is that it's unclear at usage that you can only use one of each Modifier. However, the current String API also has this problem.
Introduce a new Modifiers struct with optional properties for each Modifier, something like:
struct Modifiers {
var scale: CGFloat?
var fade = false
var transform: (CGFloat, CGFloat)?
...
}
This design is nice because it ensures one of each Modifier is used at the most. Views would also have a heroModifiers property, but would be the type of the struct. This design might be used like this:
foo.heroModifiers.scale = 0.5
foo.heroModifiers.fade = true
I'd love your opinion on this, or would love to know if you're already working on something similar. I'd love to help implement it!
I have UITabBarController, and first tab displays NavigationController.
The Root ViewController shows fine.
But if I push the second ViewController with hero enabled, then it extends edges under Tabbars, even though I unchecked the "Under Bottom Bars" in the Storyboard Option.
The weird thing is that if I select other tab and comes back to previous tab, then the viewcontroller shows correctly, not under-the-bottom-bars.
Any advice is greatly appreciated,
I wanted to add some Hero beautiful transitions between 2 controllers. The destination controller isn't completely opaque (alpha = 0.9), to let you see the original controller behind.
In this case, here are segue parameters:
Kind: present modally
Presentation: Over current Context
Transition: Default
But using Hero set self.view.alpha
to 1.0
at the end of the transition.
I just added Hero on a button, with the following modifier: zPosition(2)
Is it possible to keep some transparency using Hero?
Thanks!
I have a custom segue class that instantiates a UINavigationController
class like this:
class CustomNavSegue: UIStoryboardSegue {
override func perform() {
let nav = ModalNavigationController(rootViewController: destination)
nav.isHeroEnabled = true
nav.modalPresentationStyle = .overCurrentContext
source.present(nav, animated: true, completion: nil)
}
}
In the ModalNavigationController
viewDidLoad
I set delegate = self
since I need to perform a custom action on:
extension ModalNavigationController: UINavigationControllerDelegate {
func navigationController(_ navigationController: UINavigationController,
willShow viewController: UIViewController,
animated: Bool) {
//need to configure something on viewController.view
}
}
However, when I set nav.isHeroEnabled
I see that the navigationController's delegate gets set to Hero.shared
.
Basically both need to be the delegate even though they need different method callbacks.
Do you have any ideas for solutions?
Maybe Hero
could expose an extra navigationDelegate:UINavigationControllerDelegate
property that only replays the callbacks it receives (probaby worth doing for other delegates as well).
Hey, You noted that we can make interactive transitions. I have been scouring the example and the issues for some documentation or example, but I can't find any.
Can @lkzhao give me a few pointers? Like I'm trying to find how you did the image viewer fade animation.
Many Thanks
In the Demo, I put the “present(vc, animated: true, completion: nil)” replaced with “self.navigationController?.pushViewController(vc, animated: true)”,the view's animation effects disappear
I have removed Hero modifiers from the Demo App, one-by-one and didn't notice any difference in the App behavior running in iPhone 5(iOS 9.0) Simulator.
my CocoaPods version is 1.20rc.
When run pod search 'Hero',telling that no this libary,Is there any help?
Hope for your replay.
I really like the elegance of your API and the approach of associating pairs of views using the heroID. Sometimes, there are situations where I want to actually transfer a specific view instance from one view controller to another. This is needed for complex views with opaque state such as MKMapView
or EAGLView
. I'd love to see support for such use cases!
I would envision to associate pairs of container views with a similar heroID mechanism and then insert the view into the paired container view at the start of the transition. Of course it's a bit tricky to install new constraints etc. so we'd need an afterTransfer
configuration block or something similar where we could setup constraints.
I'm sure this would be a very useful addition! What do you think?
Hi, may somebody combine this framework with Facebook pop?
Hi,
i found a bug when using your library with an UIStackView.
On the Start of the Animation the UIStackView gets bigger.
I created an Example Project: HeroStackViewExample
Hello,
First, thank you for this amazing library \o/
I've noticed that when I push a controller on a navigation controller stack with hero enabled, the new view controller appears with an incorrect offset (below the navigation bar) when the navigationBar.isTranslucent
property is set to false
.
Regards.
Hero example works in all simulators except for the iPhone 7 and above. the animations do not work in them.. the attached video shows the issue.
hero.zip
While animating a view to a destination view where both views set layer.cornerRadius = x, hero always ignores that value and animates a rect.
I am confused about this in HeroDefaultAnimatorViewContext .swift
// duration is 0.2 @ 0 to 0.375 @ 500
defaultDuration = 0.208 + Double(movePoints.clamp(0, 500)) / 3000
After checking Duration and easing, I still cannot figure out what does the magic number 0.208
, 3000
mean.
Could you please give some tips? How is the default animation duration determined?
Thanks a lot.
In v0.1.8, some UI gliches appear when transitioning using matched views. In my case i'm doing a transition using matched views where width of both views are not exactly the same. The glitch seems to happen when removing the snapshot view. Flickering happens since width of both views do not match. This glitch didn't happen in v0.1.7.
In v0.1.9, transition using paired views only seems to work in one direction. When presenting the view controller, it seems only the default cross-fade transition occurs. On the other side, when dismissing the view controller the matched views transition works properly.
I'm presenting view controller with one simple subview using heroReplaceViewController(with: myViewController) and everything is ok with animations. But UITapGestureRecognizer that's added to subview is not working. When I replace heroReplaceViewController method with present(myViewController, animated: true, completion: nil) tap gesture recognizer is working normally.
Could this be some problem with library?
Probably related to #14
I updated the basic example to use StackViews and had a few issues:
I had to set the autolayout priority to 999 for the height constraint in a horizontal stackview and for the width constraint in a vertical stackview, otherwise, it would complain about an ambiguous layout.
The animations still look a bit off, you can see from the image below, in the 1st animation, all labels jump after the screen initially loads. The 2nd animation just doesn't look right.
I have the code I used up here:
https://github.com/felix-dumit/Hero/tree/stackview-autolayout
Thanks for this lib I think it's really awesome!
Hi,
I wanted to use these awesome animations in our project, however I'm having problems with layout. Are there any requirements for when should constrains be created in order to work with Hero correctly?
If you'd need any more details, let me know.
Thanks
Completely programmatic app. Using a collection view with a navigation controller that calls "show" to a simple detail view controller upon selecting a cell. Immediately after hitting a cell the entire screen flashes and then the smooth transition works as expected.
Hi,
I can not install the library. i Install podfile and after ?? Is there any video tutorial? I'm starting with swift.
Thank you
First — thanks for this awesome library! It'll make so many tasks so much easier.
Apologies if this a known issue, or something that can't be fixed, but I just wanted to point out that animations aren't working for me in the simulator (though they work fine on the device).
Here is a video of it working on my iPhone 6s Plus.
Here is a video of how it behaves in the simulator (iPhone 7).
When i add Hero Library manually or using Pod , Hero module not find error generate.Is this solution for import Hero in C project instead of Swift project?
our team want to import Hero into our project, but we want an OC version that may easy to maintain by us. :)
so I want to make an OC version from this repo, the copyright will still your's, I'll work as a translator
I'm trying to use Hero in view controllers created purely in code, without storyboards, with pushViewController
and it's not working:
class LiveInjection3ViewController: UIViewController, HeroViewControllerDelegate {
func heroWillStartTransition() {
// ...
}
}
let vc = LiveInjection3ViewController()
vc.isHeroEnabled = true
navigationController.pushViewController(vc, animated: true)
Is it not working because:
a) Hero supports segues only❓
b) Hero supports view controllers created with storyboard only❓
c) I missed sth else❓
💯
Hi there,
I love the idea of this library! I'm just getting started and was trying it out a bit Storyboard-only, animating a simple UIView in size and position. It works as expected, except I noticed that the view quickly flashes away (disappears) before reappearing in the animation. I'm sure I've probably just got something mis-configured, but I'm not quite sure what it is - any thoughts?
Here is a gif, and here is a link to my project (simplest possible configuration, Storyboard only!).
It would be so cool if this framework can work with React Native.
Since React Native already have declarative view informations upon each render
call (before creating the views). I am visioning that with React Native, Hero can handle all animations through out the App. If the component has Hero enabled. Then on each render
call, Hero can do a comparison and animate the changes.
This is what I originally had in mind when building Hero. Handling animations for state change through out the App. View controllers can tell Hero to animate to another state without transitioning to another view controller. but that requires building some other declarative state holder.
I have worked with React about a year ago. Loved their framework but hated the animation aspect of it. I think animation has always been a weak point for it. Would be very useful if React Native and work with Hero.
First step of course, is just to support view controller transitions in React Native. But I have no experience working with it.
What do you guys think? Is anyone familiar with it?
Hey! Amazing library, it looks stunning. 👏
I was testing it out on the Simulator but it looks like the animations are not working correctly in Xcode 8.2. Is it a bug or maybe something that should be mentioned in the README?
Testing on the device works perfectly! 😄
I added a UIVisualEffectView
to the MusicPlayer example to simulate this issue.
It breaks during the transition and also after the transition is complete it's still not the way it should be.
Console outputs this warning:
[Warning] <UIVisualEffectView 0x7fa50e80b830> is being asked to animate its opacity. This will cause the effect to appear broken until opacity returns to 1.
Code used is available here: https://github.com/felix-dumit/Hero/tree/visual-effect-snapshot
Any ideas? Maybe take a snapshot of the window at the effectView (final) bounds?
I played around with this idea here: 7d9f0f1
Still needs some work but here is an initial result:
It still breaks once the animation is complete, though.
This is probably an unrelated question, but in the above scenario, how could I make it so the effectView frame doesn't animate (i.e it already starts with the the final frame)?
How to enable Swipe to Back on pushed view-controller where Hero is enabled ?
I'm working on an integration with React Native, and I'm at the point where I think I can get this working if I have one thing: a function that will start an animation given an array of from views an and array of to views. If you look at Hero.start
, most of the code only deals these lists of views from HeroContext
.
Am I wrong in thinking that if on the React Native side I do all the work to figure out the from/to views, that I could get integration with Hero working if we provide that API? It would bypass parts of Hero that do the storyboard integration and automatically hooking up views, and only do the animations.
I'm trying to use a custom segue to slide a view from the bottom of the screen up to around 80 points from the top. This view then has a next button at the bottom, which when pressed will hopefully utilise Hero transitions.
Issue:
I can only get the transitions to work if I use hero_replaceViewController(). However, when i do use this, my view is no longer 80 points from the top but instead it is full screen again. I've tried to transform the view again at various points with no luck.
If i don't use hero_replaceViewController(), then the transitions do not work but the destination view frame is the correct size. I was thinking this may be down to me using custom storyboard segues instead of the standard push, etc?
Any thoughts?
For views that draw according their layer's content, the content mode is not recognized.
It is noticeable when animating the size of an imageView. The content of the source imageView appear to be stretched (not keeping its aspect ratio). For imageView with aspectFit or aspectFill. The correct behavior should grow the bounds while keeping the aspect ratio.
I have a fix in mind. But need some time to make the modification.
Hi lkzhao:
If there any help ,I want to use your lib into my Swift2.3 Project?
Hi,
For iOS projets it's will be great to make your component Carthage compatible
Take a look at these articles:
On your README.md
add on top and add section for the installation with Carthage.
When I clicked on the Tutorial I was presented with the "Create Page" webpage.
Im using buddybuild.com and it keeps spitting out this error causing the build to fail.
** BUILD FAILED **
170
The following build commands failed:
171
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
172
CompileSwift normal x86_64 /tmp/sandbox/workspace/Pods/Hero/Hero/CAMediaTimingFunction+Hero.swift
173
CompileSwift normal x86_64 /tmp/sandbox/workspace/Pods/Hero/Hero/HeroDefaultAnimatorViewContext.swift
174
(3 failures)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.