GithubHelp home page GithubHelp logo

tannerlinsley / springer Goto Github PK

View Code? Open in Web Editor NEW
59.0 3.0 2.0 39 KB

A spring that generates realistic easing functions

Home Page: http://codepen.io/tannerlinsley/pen/MmyMEK

License: MIT License

JavaScript 100.00%
animation physics motion easing function spring tension wobble

springer's Introduction

Springer

A spring that generates realistic easing functions

Features

  • 1 kb! (minified)
  • Tension & Wobble parameters
  • No dependencies
  • Compatible with any animation library

Demo

Installation

$ yarn add springer
# or
$ npm install springer --only=dev
CDN
<script src='https://unpkg.com/springer@latest/springer.js'></script>

Usage

  • springer(tension, wobble)
    • tension
      • The percentage of force the spring has before release.
      • Min: 0
      • Max: 1
      • Default: 0.5
    • wobble
      • The percentage of wobble, or malleability the spring exhibits
      • Min: 0
      • Max: 1
      • Default: 0.5
  • Returns an spring-based easing function

Example

import springer from 'springer' // or 'window.Springer.default' for script-tag users

const spring = springer(0.5, 0.8)

console.log(spring(0))   // 0
console.log(spring(0.2)) // 0.80516
console.log(spring(0.4)) // 1.01897
console.log(spring(0.6)) // 1.00010
console.log(spring(0.8)) // 0.99974
console.log(spring(1))   // 1

Acknowledgements

Springer is heavily inspired by React-Motion with he bulk of the difficult physics logic originally done by the amazing Cheng Lou (chenglou). Thanks Cheng!

Contributing

To suggest a feature, create an issue if it does not already exist. If you would like to help develop a suggested feature follow these steps:

  • Fork this repo
  • $ yarn
  • Implement your changes to files in the src/ directory
  • Submit PR for review

Scripts

  • $ yarn run test Runs the test suite
  • $ yarn run prepublish Builds for NPM distribution

Used By

Nozzle Logo

springer's People

Contributors

tannerlinsley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

sbtly

springer's Issues

Tension and friction

Hello,

Thank you very much for your work.

I was wondering if it was possible to convert the tension and wobble with values from the other tools (Android's StringForce, Framer's tension and friction...)

Tension is like stiffness but Wobble is different from damping?

I try to reproduce the same animations with your code.

Thanks

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.