{"id":2391,"url":"https://github.com/Touchwonders/Transition","last_synced_at":"2025-08-06T16:31:42.728Z","repository":{"id":50548100,"uuid":"84843135","full_name":"Touchwonders/Transition","owner":"Touchwonders","description":"Easy interactive interruptible custom ViewController transitions","archived":false,"fork":false,"pushed_at":"2020-11-02T08:11:20.000Z","size":11725,"stargazers_count":2641,"open_issues_count":2,"forks_count":130,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-07-29T06:18:23.564Z","etag":null,"topics":["animation","controller","custom","interactive","interuptable","ios","swift","transition","transitions","view","viewcontroller"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Touchwonders.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-13T15:31:36.000Z","updated_at":"2025-07-28T13:05:30.000Z","dependencies_parsed_at":"2022-09-18T04:41:01.720Z","dependency_job_id":null,"html_url":"https://github.com/Touchwonders/Transition","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/Touchwonders/Transition","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Touchwonders%2FTransition","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Touchwonders%2FTransition/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Touchwonders%2FTransition/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Touchwonders%2FTransition/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Touchwonders","download_url":"https://codeload.github.com/Touchwonders/Transition/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Touchwonders%2FTransition/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269112528,"owners_count":24361993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-06T02:00:09.910Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["animation","controller","custom","interactive","interuptable","ios","swift","transition","transitions","view","viewcontroller"],"created_at":"2024-01-05T20:16:12.620Z","updated_at":"2025-08-06T16:31:42.128Z","avatar_url":"https://github.com/Touchwonders.png","language":"Swift","funding_links":[],"categories":["UI","Libs","Animation","Swift","UI [🔝](#readme)","Content"],"sub_categories":["Transition","UI","Other free courses"],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"Documentation/artwork/header.png\" width=\"890\" alt=\"Transition\"/\u003e\n\u003c/div\u003e\n\n[![CocoaPods version](https://img.shields.io/cocoapods/v/Transition.svg)](https://cocoapods.org/pods/Transition) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![license](https://img.shields.io/github/license/Touchwonders/transition.svg)](https://github.com/Touchwonders/Transition/blob/master/LICENSE) [![platform](https://cocoapod-badges.herokuapp.com/p/Transition/badge.png)]()\n\n\n## Introduction\n**Transition** is a library that helps you build iOS view controller transitions. \nImplementing a nice interactive custom view controller transition involves quite a number of components. You have to implement the correct delegates, handle the switching between passive animation and active interaction phases, ensure the timing is right, think of interruption and cancellation, keep responsibilities separated... It quickly gets messy! This is where Transition helps you out: you just define the animation and the interaction, Transition ties it all together.\n\n**In short:**\n\n* You specify single-responsibility components (animation, interaction, ...)\n* Transition ties them together\n\n## Examples\n\nThere are several examples (which can be found in `Examples/`):\n\n1. **SimpleExample**: implements the basic steps explained in this README.\n2. **TabBarTransitionsExample**: shows you how to implement custom `UITabBarController` transition animations with custom interaction.\n3. **ModalTransitionsExample**: shows you how to implement custom *modal* transition animations that include interaction with a **shared element**.\n4. **BuiltInTransitionsCatalog**: shows a small collection of built-in transition animations.\n\nTo run an example project, clone the repo, navigate to one of these example directories, and run `pod install` from that directory first.\n\n---\n\n![](Documentation/artwork/tabbar.gif)![](Documentation/artwork/modal.gif)![](Documentation/artwork/navigation.gif)\n\n---\n\n## Requirements\n\n* iOS 10.0+\n* Swift 3.0+\n\n## Usage\n\n### 1. The AnimationLayer\n\nThe `AnimationLayer` is the most essential part of setting up a transition; without it, there'll be no animation. An `AnimationLayer` is a simple struct that takes two arguments:\n\n##### 1. Animation function\nThis is a simple closure with the signature `() -\u003e Void`. In this closure you define your animation, just as you would with a `UIView` or `UIViewPropertyAnimator` animation. For each `AnimationLayer`, Transition will instantiate a `UIViewPropertyAnimator`, passing it your animation block.\n\n##### 2. TimingParameters\n\nThis defines the timing of your animation. It must be a `UITimingCurveProvider`, such as an instance of `UICubicTimingParameters` or `UISpringTimingParameters`.\n\n##### _(3. AnimationRange)_\nAdditionally, you can set an `AnimationRange`, which by default is set to `AnimationRange.full`. This range defines the start and end point (as fractions of the total transition animation duration) between which your `AnimationLayer`'s animation will run.\n\nYou create your `AnimationLayer` as follows:\n\n```swift\nlet animationLayer = AnimationLayer(timingParameters: UICubicTimingParameters(animationCurve: .easeOut)\n                                           animation: { topView?.transform = targetTransform })\n```\n\n**😦 ... Hey, wait! Where do that `topView` and `targetTransform` come from?**\n\n### 2. The TransitionAnimation\n\nYour `AnimationLayer` is defined as a part of your `TransitionAnimation`. This represents all (non-interactive) animation during a transition. The `TransitionAnimation` protocol exposes an array of `AnimationLayers`. Additionally it contains two functions; one for setup and one for completion. Before starting animation, your setup function will be called, passing you the transitioningContext that among others contains the `fromView` and `toView` in the transition. The completion function is called when the entire transition completes, allowing you to clean up any temporary views added in the setup.\n\n```swift\nclass SimpleAnimation : TransitionAnimation {\n    \n    private weak var topView: UIView?\n    private var targetTransform: CGAffineTransform = .identity\n    \n    func setup(in operationContext: TransitionOperationContext) {\n        let context = operationContext.context\n        let isPresenting = operationContext.operation.isPresenting\n        \n        //  We have to add the toView to the transitionContext, at the appropriate index:\n        if isPresenting {\n            context.containerView.addSubview(context.toView)\n        } else {\n            context.containerView.insertSubview(context.toView, at: 0)\n        }\n        context.toView.frame = context.finalFrame(for: context.toViewController)\n        \n        //  We only animate the view that will be on top:\n        topView = isPresenting ? context.toView : context.fromView\n        \n        let hiddenTransform = CGAffineTransform(translationX: 0, y: -context.containerView.bounds.height)\n        \n        topView?.transform = isPresenting ? hiddenTransform : .identity\n        targetTransform = isPresenting ? .identity : hiddenTransform\n    }\n    \n    var layers: [AnimationLayer] {\n        return [AnimationLayer(timingParameters: AnimationTimingParameters(animationCurve: .easeOut), animation: animate)]\n    }\n    \n    func animate() {\n        topView?.transform = targetTransform\n    }\n    \n    func completion(position: UIViewAnimatingPosition) {}\n}\n```\n\n**🤔 ... But what about duration?**\n\n### 3. The Transition\n\nYou just defined the animation of your transition. You now create a **`Transition`** struct that has an `animation` part (your `TransitionAnimation`) and an optional `sharedElement` part, which you can see implemented in the Modal and Navigation examples. And the `Transition` has a duration!\n\n```swift\nlet transition = Transition(duration: 2.0, animation: SimpleAnimation())\n```\n\n**😬 ... And where do I put that transition?**\n\n### 4. The TransitionController\n\nAlmost there. Say you want to use this transition for `UINavigationController` transitions. Let's make a convenience object that isolates transition-related functionality for a navigationController:\n\n```swift\nclass MyNavigationTransitions {\n    let transitionController: TransitionController\n    let transitionsSource = MyNavigationTransitionSource()\n    \n    init(navigationController: UINavigationController) {\n        transitionController = TransitionController(forTransitionsIn: navigationController, transitionsSource: transitionsSource)\n    }\n}\n\nclass MyNavigationTransitionSource : TransitionsSource {\n    func transitionFor(operationContext: TransitionOperationContext, interactionController: TransitionInteractionController?) -\u003e Transition {\n        return Transition(duration: 0.5, animation: SimpleAnimation())\n    }\n}\n```\n\nThe `TransitionController` takes responsibility for animating transitions in the given navigationController, using an external `TransitionsSource` to provide operation-specific transitions (the operation – in this case push or pop – can be obtained from the `TransitionOperationContext`). This means you can return different transition animations for push and pop. You can also provide a single animation that behaves differently depending on the operation (see the `SimpleAnimation`).\n\nNow, initialize your `MyNavigationTransitions`, passing it your navigationController.\n\n**🤓 ... Is that it?**\n\nYes!\n\n😎\n\nAt least, for custom view controller transition animations. There's a lot more that'll help you set up a custom interaction gesture and a shared element that can move between the transitioning views.\n\nThe above steps are implemented in the `SimpleExample` that can be found in the `Examples/` directory.\n\n## Further reading\n\n* [Adding custom interaction](Documentation/custom_interaction.md)\n* [Adding a shared element](Documentation/shared_element.md)\n* [A note on timing](Documentation/timing.md)\n\n## Installation\n\nTransition is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'Transition'\n```\n\n## Your input is welcome!\nIf you have any suggestions, please get in touch [with us](https://twitter.com/touchwonders). Feel free to fork and submit pull requests. Also, we're Dutch, so if any naming is odd, might be improved or is just plain inappropriate, let us know!\n\n## Backlog\n* Add functioning `UIPresentationController` support (it's there, but it doesn't animate properly...)\n* Write more tests\n* See if nonlinear scrubbing (iOS 11, https://developer.apple.com/videos/play/wwdc2017/230/) can be added\n* ...?\n\n## License\n\nTransition is available under the MIT license. See the [LICENSE](LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTouchwonders%2FTransition","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTouchwonders%2FTransition","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTouchwonders%2FTransition/lists"}