{"id":13428840,"url":"https://github.com/florent37/KotlinPleaseAnimate","last_synced_at":"2025-03-16T02:30:36.575Z","repository":{"id":91120162,"uuid":"125015293","full_name":"florent37/KotlinPleaseAnimate","owner":"florent37","description":"Kotlin, please, can you animate my views ?","archived":true,"fork":false,"pushed_at":"2020-09-09T20:27:23.000Z","size":4994,"stargazers_count":558,"open_issues_count":4,"forks_count":41,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-10-27T06:39:16.441Z","etag":null,"topics":["animate","animation","animator","design","duration","interpolator","java","kotlin","material","view"],"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/florent37.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-03-13T08:12:56.000Z","updated_at":"2024-06-18T16:38:53.000Z","dependencies_parsed_at":"2024-01-14T02:38:52.241Z","dependency_job_id":"d6439735-58ae-45a6-b86a-44e96e988063","html_url":"https://github.com/florent37/KotlinPleaseAnimate","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FKotlinPleaseAnimate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FKotlinPleaseAnimate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FKotlinPleaseAnimate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FKotlinPleaseAnimate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/florent37","download_url":"https://codeload.github.com/florent37/KotlinPleaseAnimate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243815596,"owners_count":20352195,"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":["animate","animation","animator","design","duration","interpolator","java","kotlin","material","view"],"created_at":"2024-07-31T01:01:06.472Z","updated_at":"2025-03-16T02:30:36.145Z","avatar_url":"https://github.com/florent37.png","language":"Kotlin","funding_links":["https://ko-fi.com/A160LCC'"],"categories":["Libraries"],"sub_categories":[],"readme":"# Kotlin Please Animate\n\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-KotlinPleaseAnimate-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/6837)\n[![CircleCI](https://circleci.com/gh/florent37/KotlinPleaseAnimate/tree/master.svg?style=svg)](https://circleci.com/gh/florent37/NoActivityResult/tree/master)\n[![Language](https://img.shields.io/badge/language-kotlin-brightgreen.svg)](https://www.github.com/florent37/KotlinPleaseAnimate)\n\n\n`Kotlin, please, can you animate my views ?`\n\nA Kotlin way to declare and run beautiful animations ! \nPlease be gentle with Kotlin :)\n\n\u003ca href=\"https://goo.gl/WXW8Dc\"\u003e\n  \u003cimg alt=\"Android app on Google Play\" src=\"https://developer.android.com/images/brand/en_app_rgb_wo_45.png\" /\u003e\n\u003c/a\u003e\n\n[![gif](https://raw.githubusercontent.com/florent37/KotlinPleaseAnimate/master/media/sample.gif)](https://github.com/florent37/KotlinPleaseAnimate)\n\n```kotlin\nplease {\n   animate(avatar) toBe {\n      bottomOfItsParent(marginDp = 36f)\n      leftOfItsParent(marginDp = 16f)\n      width(40, keepRatio = true, toDp = true)\n   }\n}.start()\n```\n\n# Download\n\n\u003ca href='https://ko-fi.com/A160LCC' target='_blank'\u003e\u003cimg height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\n\nIn your module [![Download](https://api.bintray.com/packages/florent37/maven/KotlinPleaseAnimate/images/download.svg)](https://bintray.com/florent37/maven/KotlinPleaseAnimate/_latestVersion)\n```groovy\nimplementation 'com.github.florent37:kotlinpleaseanimate:1.0.2'\n```\n\nThis code describe the video above\n\n```kotlin\nplease(duration = 1500L) {\n   animate(avatar) toBe {\n      bottomOfItsParent(marginDp = 36f)\n      leftOfItsParent(marginDp = 16f)\n      visible()\n      width(40, keepRatio = true, toDp = true)\n   }\n   animate(name) toBe {\n      rightOf(avatar, marginDp = 16f)\n      sameCenterVerticalAs(avatar)\n      textColor(Color.WHITE)\n   }\n   animate(subname) toBe {\n      rightOf(name, marginDp = 5f)\n      sameCenterVerticalAs(name)\n      textColor(Color.WHITE)\n   }\n   animate(revert) toBe {\n      rightOfItsParent(marginDp = 4f)\n      bottomOfItsParent(marginDp = 12f)\n      backgroundAlpha(0f)\n   }\n   animate(start) toBe {\n      aboveOf(revert, marginDp = 4f)\n      rightOfItsParent(marginDp = 4f)\n      backgroundAlpha(0f)\n   }\n   animate(bottomLayout) toBe {\n      originalPosition()\n   }\n   animate(content) toBe {\n      originalPosition()\n      visible()\n   }\n}.start()\n```\n\n## Follow scroll\n\n[![gif](https://raw.githubusercontent.com/florent37/KotlinPleaseAnimate/master/media/scroll.gif)](https://github.com/florent37/KotlinPleaseAnimate)\n\nUse `setPercent` to apply modify the current step of the animation\n\nExemple with a scrollview\n\n```kotlin\nval animation = please {\n        animate(avatar) toBe {\n           topOfItsParent(marginDp = 20f)\n           leftOfItsParent(marginDp = 20f)\n           scale(0.5f, 0.5f)\n        }\n\n        animate(username) toBe {\n           rightOf(avatar, marginDp = 16f)\n           sameCenterVerticalAs(avatar)\n\n           alpha(0.5f)\n        }\n\n        animate(revert) toBe {\n           rightOfItsParent(marginDp = 20f)\n           sameCenterVerticalAs(avatar)\n        }\n\n        animate(background) toBe {\n           height(h, horizontalGravity = Gravity.LEFT, verticalGravity = Gravity.TOP)\n        }\n}\nscrollview.setOnScrollChangeListener(NestedScrollView.OnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY -\u003e\n    val percent = scrollY * 1f / v.maxScrollAmount\n    animation.setPercent(percent)\n})\n```\n\n## Chain animations\n\nJust ask the kotlin's animation if he wants to execute another animation after, using `thenCouldYou animate`\n\n```\nplease(duration = 1000L) {\n   animate(image, withCameraDistance = 500f) toBe {\n      flippedHorizontally()\n   }\n}.thenCouldYou(duration = 500L) {\n   animate(image, withCameraDistance = 1000f) toBe {\n      alpha(0.5f)\n   }\n}.start()\n```\n\n## Apply directly\n\nIf you want your animation to be applied directly, be bossy with kotlin and force it to apply it using `now()` !\n\n```kotlin\nplease {\n   animate(view) toBe {\n      outOfScreen(Gravity.BOTTOM)\n   }\n}.now();\n```\n\n## Reset\n\nUse `reset` to return to the initial state of views\n\n```kotlin\nanimation.reset():\n```\n\n# List of expectations\n\n```\nplease {\n  animate(view) { //toBe is optional\n\n     rightOf(view, marginDp=)\n     leftOf(view, marginDp=)\n     belowOf(view, marginDp=)\n     aboveOf(view, marginDp=)\n\n     originalPosition()\n\n     sameCenterAs(view, horizontal=, vertical=)\n     sameCenterHorizontalAs(view)\n     sameCenterVerticalAs(view)\n     centerInParent(horizontal=, vertical=)\n     centerVerticalInParent()\n     centerHorizontalInParent()\n\n     centerBetweenViews(view1, view2, horizontal, vertical)\n     centerBetweenViewAndParent(otherView, horizontal, vertical, toBeOnRight, toBeOnBottom)\n\n     topOfItsParent()\n     rightOfItsParent()\n     bottomOfItsParent()\n     leftOfItsParent()\n\n     alignBottom(otherView, marginDp=)\n     alignTop(otherView)\n     alignLeft(otherView)\n     alignRight(otherView)\n\n     outOfScreen(gravitiy)  //Gravity.LEFT / Gravity.RIGHT / Gravity.TOP / Gravity.BOTTOM\n\n     alpha(alpha)\n     sameAlphaAs(otherView)\n     visible()\n     invisible()\n\n     custom(object: CustomAnimExpectation(){ ... })\n\n     originalScale()\n\n     scale(scaleX, scaleY)\n     height(height, keepRatio=, useDp=)\n     width(width, keepRatio=, useDp=)\n     sameScaleAs(otherView)\n     sameWidthAs(otherView)\n     sameHeightAs(otherView)\n\n     marginTop(margin)\n     marginBottom(margin)\n     marginRight(margin)\n     marginLeft(margin)\n\n     paddingTop(padding)\n     paddingBottom(padding)\n     paddingRight(padding)\n     paddingLeft(padding)\n\n     textColor(textColor)\n     textSize(textSize)\n     backgroundAlpha(alpha)\n\n     rotated(rotation)\n     vertical(bottomOfViewAtLeft)\n     atItsOriginalRotation()\n}\n````\n\n# Credits\n\nAuthor: Florent Champigny\n\nBlog : [http://www.tutos-android-france.com/](http://www.tutos-android-france.com/)\n\nFiches Plateau Moto : [https://www.fiches-plateau-moto.fr/](https://www.fiches-plateau-moto.fr/)\n\nForked from ExpectAnim: https://github.com/florent37/ExpectAnim\n\n\u003ca href=\"https://goo.gl/WXW8Dc\"\u003e\n  \u003cimg alt=\"Android app on Google Play\" src=\"https://developer.android.com/images/brand/en_app_rgb_wo_45.png\" /\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://plus.google.com/+florentchampigny\"\u003e\n  \u003cimg alt=\"Follow me on Google+\"\n       src=\"https://raw.githubusercontent.com/florent37/DaVinci/master/mobile/src/main/res/drawable-hdpi/gplus.png\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://twitter.com/florent_champ\"\u003e\n  \u003cimg alt=\"Follow me on Twitter\"\n       src=\"https://raw.githubusercontent.com/florent37/DaVinci/master/mobile/src/main/res/drawable-hdpi/twitter.png\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://fr.linkedin.com/in/florentchampigny\"\u003e\n  \u003cimg alt=\"Follow me on LinkedIn\"\n       src=\"https://raw.githubusercontent.com/florent37/DaVinci/master/mobile/src/main/res/drawable-hdpi/linkedin.png\" /\u003e\n\u003c/a\u003e\n\n# License\n\n    Copyright 2018 florent37, Inc.\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorent37%2FKotlinPleaseAnimate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflorent37%2FKotlinPleaseAnimate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorent37%2FKotlinPleaseAnimate/lists"}