Giter VIP home page Giter VIP logo

flinger's Introduction

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.1.1'
}

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.

flinger's People

Contributors

iamjosephmj avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.