{"id":2364,"url":"https://github.com/marty-suzuki/TheAnimation","last_synced_at":"2025-08-06T12:31:47.472Z","repository":{"id":56924172,"uuid":"133116406","full_name":"marty-suzuki/TheAnimation","owner":"marty-suzuki","description":"Type-safe CAAnimation wrapper. It makes preventing to set wrong type values.","archived":false,"fork":false,"pushed_at":"2020-01-20T18:44:40.000Z","size":333,"stargazers_count":223,"open_issues_count":1,"forks_count":14,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-11-25T19:45:35.689Z","etag":null,"topics":["animation","carthage","cocoapods","ios","macos","tvos"],"latest_commit_sha":null,"homepage":"","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/marty-suzuki.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":"2018-05-12T05:17:25.000Z","updated_at":"2024-11-11T11:20:54.000Z","dependencies_parsed_at":"2022-08-20T22:50:21.073Z","dependency_job_id":null,"html_url":"https://github.com/marty-suzuki/TheAnimation","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marty-suzuki%2FTheAnimation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marty-suzuki%2FTheAnimation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marty-suzuki%2FTheAnimation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marty-suzuki%2FTheAnimation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marty-suzuki","download_url":"https://codeload.github.com/marty-suzuki/TheAnimation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228898283,"owners_count":17988652,"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":["animation","carthage","cocoapods","ios","macos","tvos"],"created_at":"2024-01-05T20:16:11.960Z","updated_at":"2024-12-09T13:30:34.518Z","avatar_url":"https://github.com/marty-suzuki.png","language":"Swift","readme":"# TheAnimation\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"http://img.shields.io/badge/platform-iOS | tvOS | macOS-blue.svg?style=flat\" alt=\"Platform\" /\u003e\n  \u003ca href=\"https://developer.apple.com/swift\"\u003e\n    \u003cimg src=\"http://img.shields.io/badge/Swift-4.1%20|%204.2%20|%205.0%20|%205.1-brightgreen.svg?style=flat\" alt=\"Language\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/Carthage/Carthage\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat\" alt=\"Carthage\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://cocoapods.org/pods/TheAnimation\"\u003e\n    \u003cimg src=\"https://img.shields.io/cocoapods/v/TheAnimation.svg?style=flat\" alt=\"Version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://cocoapods.org/pods/TheAnimation\"\u003e\n    \u003cimg src=\"https://img.shields.io/cocoapods/l/TheAnimation.svg?style=flat\" alt=\"License\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://travis-ci.org/marty-suzuki/TheAnimation\"\u003e\n    \u003cimg src=\"https://img.shields.io/travis/marty-suzuki/TheAnimation.svg?style=flat\" alt=\"CI Status\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nTheAnimation is Type-safe CAAnimation wrapper.\n\n![](./Images/basic_animation.png)\n\n## Introduction\n\nFor example, if you want to animate `backgroundColor` with `CABasicAnimation`, you need to consider type because fromValue property and so on are `Any?`.\n\n![](./Images/background_raw.png)\n\nIf you use `BasicAnimation of TheAnimation`, you can animate `backgroundColor` without considering type! (`AnimationKeyPaths.backgroundColor` is `AnimationKeyPath\u003cCGColor\u003e` type.)\n\n![](./Images/background.png)\n\n## Usage\n\nThe way of making an animation is almost similar `CAAnimation`.\nBut you need to use `animation.animate(in:)` method instead of using `layer.add(_:forKey:)`.\n\n```swift\nlet view = UIView()\n\nlet animation = BasicAnimation(keyPath: .opacity)\nanimation.fromValue = 0\nanimation.toValue   = 1\nanimation.duration  = 1\nanimation.animate(in: view)\n```\n\n`animation.animate(in:)` returns `AnimaitonCanceller`. You can cancel an animation with it.\n\n```swift\nlet canceller = animation.animate(in: view)\ncanceller.cancelAnimation()\n```\n\n## Example\n\nTo run the example project, clone the repo, and open Example directory.\n\n## Correspondence Table\n\n| CAAnimation | TheAnimation |\n| :-: | :-: |\n| CAPropertyAnimation | PropertyAnimation |\n| CABasicAnimation | BasicAnimation |\n| CAKeyframeAnimation | KeyframeAnimation |\n| CASpringAnimation | SpringAnimation |\n| CATransition | TransitionAnimation |\n| CAAnimationGroup | AnimationGroup |\n\n## Add new `AnimationKeyPath`\n\nYou can add `AnimationKeyPath` like this.\n\n```swift\nextension AnimationKeyPaths {\n    static let newKeyPath = AnimationKeyPath\u003cCGFloat\u003e(keyPath: \"abcd\")\n}\n```\n\n## Handle animation did `Start` / `Stop`\n\nYou can handle animation did **Start** with `func setAnimationDidStart(handler:)`.\nIn addition, you can handle animation did **Stop** with `func setAnimationDidStop(handler:)`.\n\n```swift\nlet view = UIView()\n\nlet animation = BasicAnimation(keyPath: .opacity)\nanimation.fromValue = 0\nanimation.toValue   = 1\nanimation.duration  = 1\n\nanimation.setAnimationDidStart {\n    // do something\n}\n\nanimation.setAnimationDidStop { finished in\n    // do something\n}\n\nanimation.animate(in: view)\n```\n\n## Requirements\n\n- Xcode 9.3\n- iOS 9 or greater\n- tvOS 9 or greater\n- macOS 10.11 or greater\n- Swift 4.2 (since 0.3.0)\n\n## Installation\n\n### Carthage\n\nIf you’re using [Carthage](https://github.com/Carthage/Carthage), simply add\nTheAnimation to your `Cartfile`:\n\n```ruby\ngithub \"marty-suzuki/TheAnimation\"\n```\n\n### CocoaPods\n\nTheAnimation is available through [CocoaPods](https://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'TheAnimation'\n```\n\n## Author\n\nmarty-suzuki, s1180183@gmail.com\n\n## License\n\nTheAnimation is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":["UI","Libs","Animation [🔝](#readme)"],"sub_categories":["Animation"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarty-suzuki%2FTheAnimation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarty-suzuki%2FTheAnimation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarty-suzuki%2FTheAnimation/lists"}