Giter VIP home page Giter VIP logo

motus's Introduction

motus

Motus Logo

Build Status

Animation library that mimics CSS keyframes when scrolling.

Installation

As npm package

npm i -S motus

Standalone script file

<script src="dist/motus.js"></script>

Usage

Basic usage

const myAnimation = new Motus.Animation(
    new Motus.Point(100), // set animation start position in px
    new Motus.Point(200), // set animation end position in px
    {
        50: { // make font size 10 px before it hits 50% of the distance (in this case <150px)
            fontSize: 10, // px by default
        },
        100: { // make font size 20 px after 50%
            fontSize: 20, // px by default
        }
    }
);
Motus.add(myAnimation);

Different usages

/********************************************
    Different ways of defining keyframes
*********************************************/
const k1 = {
    50: {
        'font-size': {
            to: 10, // px by default
        }
    },
    100: {
        'font-size': {
            to: 20,
        }
    }
}
//*******************************************
const k2 = {
    50: {
        'font-size': {
            from: '5em', // initial value (in this case at 0%)
            to: '10em',
        }
    },
    100: {
        fontSize: {
            from: '10em',
            to: '20em',
        }
    }
}
//*******************************************
const k3 = {
    50: {
        fontSize: {
            to: 10,
            unit: 'em',
        }
    },
    100: {
        'font-size': {
            from: 10,
            to: 20,
            unit: 'em',
        }
    }
}

const mYaNiMaTiOn = new Motus.Animation(
    new Motus.Point(document.getElementById('start-point')), // dom elements instead of px
    new Motus.Point(document.getElementById('end-point')),
    k1 || k2 || k3 // your choice
);
Motus.add(mYaNiMaTiOn);

Development

npm run tsc - compiles ts files in js files

npm run build - watches for changes and compiles ts files into dist in develompent mode

npm run watch - watches for changes and compiles with build ts files into dist

npm run prod - watches for changes and compiles ts files into dist in production mode

License

MIT

motus's People

Contributors

alexcambose avatar

Watchers

James Cloos avatar Darryl Walker 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.