Git Product home page Git Product logo

color-transitions's Introduction

color-transitions Build Status Coverage Status

Smooth color transitions

Experimental module

Visual demo

Install

$ npm install --save color-transitions

Usage

const colorTransitions = require('color-transitions');

colorTransitions('blue', 'red', color => {
	// `color` will be the color value between 'blue' and 'red'
});

API

colorTransitions(color1, color2, [options], cb)

color1, color2

Same as the color setter.

options

duration

Type: number
Default: 1000

The transition duration option specifies the number of seconds or milliseconds a transition animation should take to complete.

timing

Type: string or function
Default: 'linear'

The transition timing function option is used to describe how the intermediate values of the color being affected by a transition effect are calculated. This in essence lets you establish an acceleration curve, so that the speed of the transition can vary over its duration.

If this is string, the function would be from eases.

threshold

Type: number
Default: 60

Maximum number of callbacks that can occur in one second.

iterations

Type: number or boolean
Default: 1

How many transitions between two colors. Specify true to make it infinite.

cb

Type: function

Callback function. If return false, stop immediately.

cb(color, delta, iteration)
color

Type: array

RGB array

delta

Type: number

How much time has passed since last callback in milliseconds.

iteration

Type: number

Which iteration. Counting from 1.

done

Type: boolean

Is the transition done?

License

MIT © Steve Mao

color-transitions's People

Contributors

stevemao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

color-transitions's Issues

Demo janks in browser

The demo somehow says it has long frames. Although this is not for the use in the browsers, it shouldn't perform bad. I guess the reason might be because it's not in sync with the browser DOM clock. Please comment :)

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.