{"id":16426802,"url":"https://github.com/lcdsmao/springx","last_synced_at":"2025-03-16T17:34:37.512Z","repository":{"id":48385350,"uuid":"187489244","full_name":"lcdsmao/SpringX","owner":"lcdsmao","description":"SpringX is an Android library that allows developers to easily use SpringAnimation","archived":false,"fork":false,"pushed_at":"2021-08-02T20:34:09.000Z","size":2627,"stargazers_count":103,"open_issues_count":12,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-11T08:10:42.653Z","etag":null,"topics":["android","androidanimation","animation","kotlin-android","springanimation","springanimator"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lcdsmao.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":"2019-05-19T14:45:30.000Z","updated_at":"2024-01-28T16:08:55.000Z","dependencies_parsed_at":"2022-09-09T16:30:53.540Z","dependency_job_id":null,"html_url":"https://github.com/lcdsmao/SpringX","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/lcdsmao%2FSpringX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lcdsmao%2FSpringX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lcdsmao%2FSpringX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lcdsmao%2FSpringX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lcdsmao","download_url":"https://codeload.github.com/lcdsmao/SpringX/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221666411,"owners_count":16860415,"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":["android","androidanimation","animation","kotlin-android","springanimation","springanimator"],"created_at":"2024-10-11T08:10:26.740Z","updated_at":"2024-10-27T10:59:18.828Z","avatar_url":"https://github.com/lcdsmao.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SpringX\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[ ![Download](https://api.bintray.com/packages/lcdsmao/maven/springx/images/download.svg) ](https://bintray.com/lcdsmao/maven/springx/_latestVersion)\n![CI](https://github.com/lcdsmao/SpringX/workflows/Android%20CI/badge.svg)\n\nSpringX is an Android library that allows developers to easily use [SpringAnimation](https://developer.android.com/guide/topics/graphics/spring-animation).\n\n## Demo\n\n| [Demo1](./sample/src/main/java/com/github/lcdsmao/springsample/DragExampleFragment.kt) | [Demo2](./sample/src/main/java/com/github/lcdsmao/springsample/SpringMoveItemAnimator.kt) |\n|-|-|\n| \u003cimg src='./art/anim1.gif' width='256'\u003e | \u003cimg src='./art/anim2.gif' width='256'\u003e |\n\n\n## Setup\n\nInclude the jcenter repository to your root `build.gradle` file:\n```gralde\nrepositories {\n  jcenter()\n}\n```\n\nAnd then add dependency to your module `build.gradle`:\n```gradle\ndependencies {\n  implementation 'com.github.lcdsmao:springx:0.0.2'\n}\n```\n\n## Usage\n\nYou can manually create the `ViewPropertySpringAnimator` or use the extension function:\n \n```kotlin\nval spring = ViewPropertySpringAnimator(view) // Always create a new one\n// or\nval spring = view.spring() // Reuse the one that associated with this view\n```\n\nThe syntax of `ViewPropertySpringAnimator` is simliar to `ViewPropertyAnimator`:\n\n```kotlin\nspring\n  .rotation(30f)\n  .scaleX(2f)\n  .scaleY(2f)\n  .y(500f)\n  .x(500f)\n  .start()\n```\n\nComplicated controls are also allowed:\n\n```kotlin\nspring\n  .defaultDampingRatio(0.7f) // default damping ratio for all animations\n  .defaultStiffness(5f) // default stiffness for all animations\n  .rotation(30f)\n  .translationX(100f) {\n      startVelocity = 30f // set start velocity of TRANSLATION_X\n      dampingRatio = 0.3f // override the damping ratio\n      onUpdate { spring, value, velocity -\u003e\n        // the update listener that associated with TRANSLATION_X\n      }\n  }\n  .translationY(200f) {\n      onUpdate { spring, value, velocity -\u003e\n        // the update listener that associated with TRANSLATION_Y\n      }\n      onEnd { spring, canceled, value, velocity -\u003e\n        // the end listener that associated with TRANSLATION_Y\n      }\n  }\n  .setListener(\n      onEnd = {\n        // the end listener will be called when all animations end\n      }\n  )\n```\n\n## Thanks\n\nThis library is inspired by the talk: [Motional Intelligence: Build Smarter Animations (Google I/O'19)\n](https://youtu.be/f3Lm8iOr4mE?t=709)\n\n## Related Articles\n\n- [Motional Intelligence: Build smarter animations](https://medium.com/androiddevelopers/motional-intelligence-build-smarter-animations-821af4d5f8c0)\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n## License\n\n```\nCopyright 2019 Mao Yufeng\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flcdsmao%2Fspringx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flcdsmao%2Fspringx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flcdsmao%2Fspringx/lists"}