{"id":17225084,"url":"https://github.com/zoonooz/transitkit","last_synced_at":"2025-04-14T00:51:40.761Z","repository":{"id":56924482,"uuid":"53250587","full_name":"zoonooz/TransitKit","owner":"zoonooz","description":"easy custom ios transition","archived":false,"fork":false,"pushed_at":"2016-04-07T15:26:42.000Z","size":1759,"stargazers_count":61,"open_issues_count":1,"forks_count":9,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-11T06:04:12.700Z","etag":null,"topics":[],"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/zoonooz.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":"2016-03-06T11:06:20.000Z","updated_at":"2024-10-17T02:23:44.000Z","dependencies_parsed_at":"2022-08-20T22:50:21.312Z","dependency_job_id":null,"html_url":"https://github.com/zoonooz/TransitKit","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoonooz%2FTransitKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoonooz%2FTransitKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoonooz%2FTransitKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoonooz%2FTransitKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zoonooz","download_url":"https://codeload.github.com/zoonooz/TransitKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248804773,"owners_count":21164131,"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","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":[],"created_at":"2024-10-15T04:12:40.013Z","updated_at":"2025-04-14T00:51:40.736Z","avatar_url":"https://github.com/zoonooz.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/zoonooz/TransitKit/master/TransitKit.jpg\"/\u003e\u003c/p\u003e\n\n# 🚃 TransitKit\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\n\n**TransitKit** is the library provide you an easiest way to customize the animation when you change from one ViewController to another. You can think of this library as transit system, travel from one station to other station with trains in various lines.\n\nBesides custom transition, Transit also helps you move subviews to the next ViewController with your custom animation.\n\nTransit consists of four parts\n- **Station** is each view controller you animating to or from\n- **Passenger** is the subviews inside you view controller that you want to animate separately\n- **Train** is the data mover that move passengers from one station to another\n- **Line** is the animator to tell the library that how you going to animate between view controller\n\n## 🚉 Station (駅)\nStation is your view controllers\n```\ntypealias Station = UIViewController\n```\nMost of the time you are dealing with simple view controller, only if you want to send some passengers to another station then have to extend `StationPassenger` protocol and return the list of passengers you want them to travel.\n\n## 👫 Passenger (旅客)\nPassengers are your subviews inside the root view in view controller. They can be identified by `name`. If both current train and destination station have same passenger with same name, thats mean passenger is traveling!\n```\nstruct Passenger {\n    var name: String\n    var view: UIView\n}\n```\n\n## 🚇 Train (電車)\nTrain knows which station they coming from and going to including the passengers on board. You will not use the train directly because the station will create the train for you.\n\n## 🚦 Line (線)\nLine is the most important part here to create the animation. There are three Line protocols for you to use.\n- **AnimationLine** normal line for `UIView` animation based\n- **ProgressLine** use `CADisplayLink` for animation\n- **InteractionLine** for interaction transition.\n\nAnimationLine | ProgressLine | InteractionLine\n---| --- | ---\n![](https://raw.githubusercontent.com/zoonooz/TransitKit/master/line_animation.gif) | ![](https://raw.githubusercontent.com/zoonooz/TransitKit/master/line_progress.gif) | ![](https://raw.githubusercontent.com/zoonooz/TransitKit/master/line_interaction.gif)\n\n## How to use\n#### 1. Implement Line protocol\nThere are three functions in every line you have to implement\n- `func duration() -\u003e NSTimeInterval` animation duration\n- `func beforeDepart(fromView:toView:inView:direction:)` run before animation start\n- `func afterArrived(fromView:toView:inView:direction:)` run after animation finished\n\n`fromView` is current ViewController's view\u003cbr/\u003e\n`toView` is ViewController's view that going to appear\u003cbr/\u003e\n`inView` is container view that has `fromView` and `toView` animating inside\u003cbr/\u003e\n`direction` can be `.Go` for show modal or push and `.Return` for dismissal or pop\u003cbr/\u003e\n\n##### Animation Line\nBasically animation line do nothing but expect you to create animation in these functions\n- `func animate(fromView:toView:inView:direction:)` create transition animation block here\n- `func animatePassenger(view:targetFrame:direction:)` create animation block for each subview\n\n##### Progress Line\nProgress line use `CADisplayLink` to manage the animation frame and pass the progress value to these functions\n- `func progress(fromView:toView:inView:direction:progress:)`\n- `func progressPassenger(view:fromFrame:toFrame:direction:progress:)`\n\n##### Interaction Line\nFor Interaction line, you have to manage the progress by yourself and pass the value back to Transit through these functions\n- `func updateInteractLine(percentComplete:)`\n- `func finishInteractionLine(withVelocity:)`\n- `func cancelInteractionLine(withVelocity:)`\n\nand Transit will call these functions in your implementation\n- `func progress(fromView:toView:inView:direction:progress:)`\n- `func progressPassenger(view:fromFrame:toFrame:direction:progress:)`\n- `func interactFinish(fromView:toView:inView:direction:lastProgress:velocity:) -\u003e NSTimeInterval`\n- `func interactCancel(fromView:toView:inView:direction:lastProgress:velocity:) -\u003e NSTimeInterval`\n- `func interactPassengerFinish(view:toFrame:duration:)`\n- `func interactPassengerCancel(view:toFrame:duration:)`\n\nSee [this](https://github.com/zoonooz/TransitKit/tree/master/Example/Lines) for example of implementation\n\n#### 2. Passengers\nIf you want to animate subviews with the transition, both ViewControllers have to extends `StationPassenger` and return all the Passengers with the same name.\n```\npublic protocol StationPassenger {\n    func allPassengers() -\u003e [Passenger]\n}\n```\n#### 3. Travel!\n\nFor modal use\n- `func travelBy(line: Line, to: Station) -\u003e Transit`\n- `func travelBackBy(line: Line) -\u003e Transit`\n\nFor NavigationController use\n- `func travelPushBy(line: Line, to: Station) -\u003e Transit`\n- `func travelPushBy(line: InteractionLine, to: Station, normalLine: Line) -\u003e Transit`\n- `func travelPopBy(line: InteractionLine) -\u003e Transit`\n\nAs NavigationController can pop with or without interaction. If you use InteractionLine, you have to provide the AnimationLine or ProgressLine for default pop animation.\n\n#### Example\nYou can see example of Line implementation in example project and use travel methods to start the transition.\n```\nlet vc = storyboard?.instantiateViewControllerWithIdentifier(\"vc\")\ntravelBy(SlideInZoomOutAnimation(), to: vc!)\n```\n\n## Installation\n#### Carthage\n```\ngithub \"zoonooz/TransitKit\"\n```\n## Author\nAmornchai Kanokpullwad, [@zoonref](https://twitter.com/zoonref)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoonooz%2Ftransitkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzoonooz%2Ftransitkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoonooz%2Ftransitkit/lists"}