Lightweight library to tweak the fling behaviour in Android. This library is only compatible with Jetpack-Compose.

Overview

Spruce Logo

Flinger (Only compatible with compose)

CircleCI Build Status License MIT Public Yes

What is Flinger?

Flinger is a plugin that is made on top of jetpack compose that will help the developer to tweak the LazyList's fling behaviour. This Library will help the developers to change the fling behaviours much easier without digging deep. Here is a prototype of Flinger:

Gradle

Add the following to your project's root build.gradle file

repositories {
    maven {
        url "https://jitpack.io"
    }
}

Add the following to your project's build.gradle file

dependencies {
    implementation 'com.github.iamjosephmj:flinger:1.0.2'
}

Basics

By the launch of Jetpack compose at least some of you might have thought if did they port the old scroll behaviour to it. The answer to that is YES, they had ported the old Overscroller behaviour to the latest compose. The Overscroller is the component that is responsible for flings in ScrollView/RecyclerViews in Android. If we dig deeper into the implementation of the Overscroller, you can see that Android uses a fixed set of values so that the flings will look almost similar throughout different devices. The whole idea behind the creation of this library is that the developers will have full access to all the internal parameters that governs the fling behaviour. This library can be easily integrated with the LazyColumns , LazyRows , LazyLists that is provided by compose.

Usage

Refer to the Sample project under to get more insights about the implementation.

LazyColumn(
    flingBehavior = flingBehavior(

        ScrollViewConfiguration.Builder()
            /*
             * This variable manages the friction to the scrolls in the LazyColumn
             */
            .scrollViewFriction(0.008f)

            /*
             * This is the absolute value of a velocity threshold, below which the
             * animation is considered finished.
             */
            .absVelocityThreshold(0f)

            /*
             * Gravitational obstruction to the scroll.
             */
            .gravitationalForce(9.80665f)

            /*
             * Scroll Inches per meter
             */
            .inchesPerMeter(39.37f)

            /*
             * Rate of deceleration of the scrollView.
             */
            .decelerationRate((ln(0.78) / ln(0.9)).toFloat())

            /*
             * Friction at the time of deceleration.
             */
            .decelerationFriction(0.09f)

            /*
             * Inflection is the place where the start and end tension lines cross each other.
             */
            .splineInflection(0.1f)

            /*
             * Spline's start tension.
             */
            .splineStartTension(0.1f)

            /*
             * Spline's end tension.
             */
            .splineEndTension(1.0f)

            /*
             * number of sampling points in the spline
             */
            .numberOfSplinePoints(100)

            // builder pattern.
            .build(),
    )
)
{
    // Columns/Rows
}

Stock Behaviours

If you are not comfortable with tweaking values, we provide you some pre-defined methods that can be used to bring the behaviour to your project, you can refer to StockFlingBehaviours.kt

Custom Behaviours

If you are interested in designing your own behaviours for the Flings, you can tryout different possibilities in the Flinger app

Contribution, Issues or Future Ideas

If part of Flinger is not working correctly be sure to file a Github issue. In the issue provide as many details as possible. This could include example code or the exact steps that you did so that everyone can reproduce the issue. Sample projects are always the best way :). This makes it easy for our developers or someone from the open-source community to start working!

If you have a feature idea submit an issue with a feature request or submit a pull request and we will work with you to merge it in!

Contribution guidelines

Contributions are more than welcome!

  • You should make sure that all the test are working properly.
  • You should raise a PR to develop branch
  • Anyone can contribute fling behaviours to StockFlingBehaviours.kt .
  • Before you raise a PR please make sure your code had no issue from Android studio lint analyzer.

Please Share & Star the repository to keep me motivated.

You might also like...
Learn Jetpack Compose for Android by Examples. Learn how to use Jetpack Compose for Android App Development. Android’s modern toolkit for building native UI.
Learn Jetpack Compose for Android by Examples. Learn how to use Jetpack Compose for Android App Development. Android’s modern toolkit for building native UI.

Learn Jetpack Compose for Android by Examples. Learn how to use Jetpack Compose for Android App Development. Android’s modern toolkit for building native UI.

A lightweight state management library for Compose Multiplatform.

Staccato A lightweight state management library for Compose Multiplatform. The term staccato (pronounced "stuh-caw-toe") means detached, or separated,

Jetpack Compose Boids | Flocking Insect 🐜. bird or Fish simulation using Jetpack Compose Desktop πŸš€, using Canvas API 🎨
Jetpack Compose Boids | Flocking Insect 🐜. bird or Fish simulation using Jetpack Compose Desktop πŸš€, using Canvas API 🎨

🐜 🐜 🐜 Compose flocking Ants(boids) 🐜 🐜 🐜 Jetpack compose Boids | Flocking Insect. bird or Fish simulation using Jetpack Compose Desktop πŸš€ , usi

A collection of animations, compositions, UIs using Jetpack Compose. You can say Jetpack Compose cookbook or play-ground if you want!
A collection of animations, compositions, UIs using Jetpack Compose. You can say Jetpack Compose cookbook or play-ground if you want!

Why Not Compose! A collection of animations, compositions, UIs using Jetpack Compose. You can say Jetpack Compose cookbook or play-ground if you want!

This is a sample app(For beginners - App #2) built using Jetpack Compose. It demonstrates the concept of State Hoisting in Jetpack Compose.
This is a sample app(For beginners - App #2) built using Jetpack Compose. It demonstrates the concept of State Hoisting in Jetpack Compose.

JetBMICalculator This is a sample app(For beginners - App #2) built using Jetpack Compose. It demonstrates the concept of State Hoisting in Jetpack Co

Jetpack-Compose-Demo - Instagram Profile UI using Jetpack Compose
Jetpack-Compose-Demo - Instagram Profile UI using Jetpack Compose

Jetpack-Compose-Demo Instagram Profile UI using Jetpack Compose

Jetpack-compose-animations-examples - Cool animations implemented with Jetpack compose
Jetpack-compose-animations-examples - Cool animations implemented with Jetpack compose

Jetpack-compose-animations-examples This repository consists of 4 animations: St

Compose-navigation - Set of utils to help with integrating Jetpack Compose and Jetpack's Navigation

Jetpack Compose Navigation Set of utils to help with integrating Jetpack Compose

Jetpack-compose-uis - A collection of some UIs using Jetpack Compose. built using Katalog

Jetpack Compose UIs This is a collection of some UIs using Jetpack Compose. It i

Comments
  • Sample APK can't be installed

    Sample APK can't be installed

    ADB error reads: Performing Streamed Install adb: failed to install flinger.apk: Failure [INSTALL_PARSE_FAILED_NOT_APK: Failed to parse /data/app/vmdl1666857912.tmp/base.apk: Failed to load asset path /data/app/vmdl1666857912.tmp/base.apk]

    OnePlus 8 Pro running Android 11

    opened by ptrckSTL 2
Releases(1.1.1)
Owner
Joseph James
Android Developer at @cred.ai. @qburst alumini
Joseph James
Zoom Modifiers, zoomable image and layouts with limit pan bounds, fling and moving back to valid bounds and callbacks that return current transformation or visible image section

Zoom Modifiers, zoomable image and layouts with limit pan bounds, fling and moving back to valid bounds and callbacks that return current transformation or visible image section

Smart Tool Factory 20 Dec 13, 2022
🎺 Orchestra is a collection of Android custom view compatible libraries for Jetpack Compose.

Orchestra ?? Jetpack Compose compatible libraries using Balloon, ColorPickerView, PowerSpinner. Balloon Add below codes to your root build.gradle file

Jaewoong Eum 408 Jan 4, 2023
Simple parallax effect for your image. Only usable with Jetpack Compose.

Parallax Effect in Compose Image Example usage // In an activity or fragment... private lateinit var gravitySensorDefaulted: GravitySensorDefaulted o

Yunus Emre OCAK 2 Jul 5, 2022
Android.compose.squircle - Android LightWeight Squircle Library for JetPack Compose

Android LightWeight Squircle Library for JetPack Compose Usage Based on Compose

Quang Nguyen 9 Jul 5, 2022
A lightweight library for using Material Colors in Android Jetpack Compose Project πŸš€πŸš€πŸš€

How To Use Step 1: Add the JitPack repository to your build file. Add it in your root build.gradle / build.gradle.kts at the end of repositories: Groo

Atick Faisal 9 Sep 9, 2022
Holi is a lightweight Jetpack Compose library of colors, gradients and cool utility functions for all your palette needs!

Holi A library of colors, gradients and utils built using Jetpack Compose for Android Features A wide collection of colors from different palettes for

Siddhesh Patil 167 Dec 5, 2022
Holi is a lightweight Jetpack Compose library of colors, gradients and cool utility functions for all your palette needs!

Holi is a lightweight Jetpack Compose library of colors, gradients and cool utility functions for all your palette needs!

Sid Patil 167 Dec 5, 2022
A lightweight particle system for Jetpack Compose - Quarks

compose-particle-system Quarks is a lightweight particle system for Jetpack Compose. There are endless possibilities for creating generative art with

Nikhil Chaudhari 41 Dec 28, 2022
Fast android task that finished in only 3 hours, it gets the information from national number without database. I just wanna refine my skills in android basics so I try to make this simple project.

RaqmQawmy it is a fast android task that finished in only 3 hours, it gets the information from national number without database. I just wanna refine

Mahmoud Abdelazim 3 May 15, 2022
Make your device sip only small amounts of battery when not in use.

trickle Make your device sip only small amounts of battery when not in use. What Automatically place your device into battery-saver mode when the scre

pyamsoft 3 Dec 21, 2022