usablica / kissui.scrollanim

CSS3 scroll animation library
http://scrollanim.kissui.io/
MIT License
1.42k stars 131 forks source link
animation animations-scrollanim css3 javascript viewport

kissui.scrollanim

CSS3 scroll animation library

This library is a part of Kissui project.

Install

Bower

You can use bower to install the package:

bower install kissui.scrollanim

CDN

You can use cdnjs: https://cdnjs.com/libraries/kissui.scrollanim

Manually

You can also download and include files manually from the latest releases.

Getting Started

This projects doesn't have any dependecies. All you need to do is to include the scrollanim.js and scrollanim.css in your page.

Please note that you don't need jQuery, Angular.js, React, Whatever.

Write your first awesome scroll animation:

<p data-kui-anim="fadeIn">Show this with fade-in</p>

Simple, isn't it?

Need more help? have a look at /example folder in the project OR http://scrollanim.kissui.io

Adding animations

You can add animations using data-kui-... attributes or programmatiaclly using the kissuiScrollAnim.add method. Read following sections for more details.

data-kui attributes

Currently we have two attributes to define the options:

Example:

<div data-kui-anim="fadeIn" data-kui-event="top">

Programmatically (JSON)

Also, you can use the kissuiScrollAnim.add method to add the animations.

Example:

kissuiScrollAnim.add(element, {
  'in': 'fadeIn'
});

Options

There are some options to define the default values in Scrollanim.

To alter event you can use setOption or setOptions methods:

kissuiScrollAnim.setOption('autoReset', false)

or

kissuiScrollAnim.setOptions({ 
  'autoReset': false,
  'triggerOnInit': false
})

Events

Scrollanim uses kissui.position to manage and track elements. Please note that kissui.position is a builtin dependency and you don't need to include anything in your page.

Kissui.position supports these events:

Also, it is possible to use a compond of events together, e.g. center middle, in right or out left. Please check out kissui.position for more information.

It is possible to use both data-kui-anim attribute and kissuiScrollAnim.add(element, event) to bind an element and reveal it after scrolling but please note that data-kui-anim attribute uses in event of kissui.position by default.

An example of adding an element using the API:

kissuiScrollAnim.add(element, {
  'in': 'fadeIn'
});

Or

kissuiScrollAnim.add(element, {
  'center middle': 'fadeIn'
});

Or

kissuiScrollAnim.add(element, {
  'center middle': 'fadeIn',
  'out': 'fadeOut'
});

Super cool.

Animations

Scrollanim uses Animate.css as a builtin dependency to provide stunnishing animations.

Here is a list of supported animations:

We always keep an up-to-date version on Animate.css.

Author

Afshin Mehrabani

Thanks to Daniel Eden for making animate.css

License

MIT