{"id":18269918,"url":"https://github.com/rubensousa/GravitySnapHelper","last_synced_at":"2025-04-04T23:31:42.686Z","repository":{"id":39617567,"uuid":"67013973","full_name":"rubensousa/GravitySnapHelper","owner":"rubensousa","description":"A SnapHelper that snaps a RecyclerView to an edge.","archived":false,"fork":false,"pushed_at":"2022-01-24T11:27:08.000Z","size":83050,"stargazers_count":5007,"open_issues_count":6,"forks_count":617,"subscribers_count":95,"default_branch":"master","last_synced_at":"2025-04-03T19:11:04.322Z","etag":null,"topics":["recyclerview","snapping"],"latest_commit_sha":null,"homepage":"","language":"Java","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/rubensousa.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-31T07:25:23.000Z","updated_at":"2025-03-31T22:36:55.000Z","dependencies_parsed_at":"2022-07-13T09:10:27.982Z","dependency_job_id":null,"html_url":"https://github.com/rubensousa/GravitySnapHelper","commit_stats":null,"previous_names":["rubensousa/recyclerviewsnap"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubensousa%2FGravitySnapHelper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubensousa%2FGravitySnapHelper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubensousa%2FGravitySnapHelper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubensousa%2FGravitySnapHelper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubensousa","download_url":"https://codeload.github.com/rubensousa/GravitySnapHelper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266476,"owners_count":20910831,"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":["recyclerview","snapping"],"created_at":"2024-11-05T11:37:53.891Z","updated_at":"2025-04-04T23:31:37.675Z","avatar_url":"https://github.com/rubensousa.png","language":"Java","readme":"# GravitySnapHelper\n\nA SnapHelper that snaps a RecyclerView to an edge.\n\n## Setup\n\nAdd this to your build.gradle:\n\n```groovy\nimplementation 'com.github.rubensousa:gravitysnaphelper:2.2.2'\n```\n\n## How to use\n\nYou can either create a GravitySnapHelper, or use GravitySnapRecyclerView.\n\nIf you want to use GravitySnapHelper directly, \nyou just need to create it and attach it to your RecyclerView:\n\n```kotlin\nval snapHelper = GravitySnapHelper(Gravity.START)\nsnapHelper.attachToRecyclerView(recyclerView)\n```\n\nIf you want to use GravitySnapRecyclerView, you can use the following xml attributes for customisation:\n\n```xml\n\u003cattr name=\"snapGravity\" format=\"enum\"\u003e\n\u003cattr name=\"snapEnabled\" format=\"boolean\" /\u003e\n\u003cattr name=\"snapLastItem\" format=\"boolean\" /\u003e\n\u003cattr name=\"snapToPadding\" format=\"boolean\" /\u003e\n\u003cattr name=\"snapScrollMsPerInch\" format=\"float\" /\u003e\n\u003cattr name=\"snapMaxFlingSizeFraction\" format=\"float\" /\u003e\n```\n\nExample:\n\n```xml\n\u003ccom.github.rubensousa.gravitysnaphelper.GravitySnapRecyclerView\n    android:id=\"@+id/recyclerView\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\"\n    app:snapGravity=\"start\" /\u003e\n```\n\n## Start snapping\n\n```kotlin\nval snapHelper = GravitySnapHelper(Gravity.START)\nsnapHelper.attachToRecyclerView(recyclerView)\n```\n\n\u003cimg src=\"screens/snap_start.gif\" width=350\u003e\u003c/img\u003e\n\n## Center snapping\n\n```kotlin\nval snapHelper = GravitySnapHelper(Gravity.CENTER)\nsnapHelper.attachToRecyclerView(recyclerView)\n```\n\n\u003cimg src=\"screens/snap_center.gif\" width=350\u003e\u003c/img\u003e\n\n## Limiting fling distance\n\nIf you use  **setMaxFlingSizeFraction** or **setMaxFlingDistance** \nyou can change the maximum fling distance allowed.\n\n\u003cimg src=\"screens/snap_fling.gif\" width=350\u003e\u003c/img\u003e\n\n\n## With decoration\n\n\u003cimg src=\"screens/snap_decoration.gif\" width=350\u003e\u003c/img\u003e\n\n## Features \n\n1. **setMaxFlingDistance** or **setMaxFlingSizeFraction** - changes the max fling distance allowed.\n2. **setScrollMsPerInch** - changes the scroll speed.\n3. **setGravity** - changes the gravity of the SnapHelper.\n4. **setSnapToPadding** - enables snapping to padding (default is false)\n5. **smoothScrollToPosition** and **scrollToPosition**\n6. RTL support out of the box\n\n## Nested RecyclerViews\n\nTake a look at these blog posts if you're using nested RecyclerViews\n\n1. [Improving scrolling behavior of nested RecyclerViews](https://rubensousa.com/2019/08/16/nested_recyclerview_part1/)\n\n2. [Saving scroll state of nested RecyclerViews](https://rubensousa.com/2019/08/27/saving_scroll_state_of_nested_recyclerviews/)\n\n\n## License\n\n    Copyright 2018 The Android Open Source Project\n    Copyright 2019 Rúben Sousa\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","funding_links":[],"categories":["snapping"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubensousa%2FGravitySnapHelper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubensousa%2FGravitySnapHelper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubensousa%2FGravitySnapHelper/lists"}