Skip to content

Commit

Permalink
Edit and correct readme for better readability (#4)
Browse files Browse the repository at this point in the history
* edit readme for better readability and correct english

* add browser compatibility note

* edit readme package weight and wording
  • Loading branch information
Marek Pietrzak authored and mciastek committed Sep 13, 2018
1 parent c7dc84d commit f2f72b9
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions README.md
@@ -1,8 +1,10 @@
# Sal [![npm version](https://badge.fury.io/js/sal.js.svg)](https://www.npmjs.com/package/sal.js) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/mciastek/sal/blob/master/LICENSE) [![Build Status](https://travis-ci.org/mciastek/sal.svg?branch=master)](https://travis-ci.org/mciastek/sal)

Performance focused, lightweight (less than **2.5 kb**) scroll animation library, written in vanilla JavaScript. No dependencies!
Performance focused, lightweight (less than **2.8 kb**) scroll animation library, written in vanilla JavaScript. No dependencies!

**Sal** (_Scroll Animation Library_) is written with aim to provide performant and lightweight solution for animating elements on scroll. It's based on the [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API), which gives amazing performance in terms of checking the element's presence in viewport.
**Sal** (_Scroll Animation Library_) was created to provide a performant and lightweight solution for animating elements on scroll. It's based on the [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API), which gives amazing performance in terms of checking the element's presence in the viewport.

**Note:** Intersection Observer API is an experimental technology so be sure to consult the [browser compatibility table](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#Browser_compatibility) and consider using a [polyfill](https://github.com/w3c/IntersectionObserver/tree/master/polyfill).

## Table of Contents
- [Install](#install)
Expand All @@ -22,7 +24,7 @@ $ npm install --save sal.js
$ yarn add sal.js
```

Then load it with your favorite module loader or use as global, when no modules
Load it with your favorite module loader or use as a global variable

```js
// ES6 modules
Expand All @@ -44,36 +46,36 @@ And remember to add styles

## Usage

In HTML, add `data-sal`, which value is animation name, e.g.:
In HTML, add a `data-sal` attribute with the animation name as value, e.g.:

```html
<div data-sal="<animation-name>"></div>
<div data-sal="fade"></div>
```

Then simply init Sal in your script file:
Then simply initialize Sal in your script file:

```js
sal();
```

It will look for an element with `data-sal` attribute and launch animation, when it's in viewport.
It will look for all elements with a `data-sal` attribute and launch their animation when in viewport.

## Animations
With **sal.js** you can easily change animation's options, by adding a proper `data` attribute:
- `data-sal-duration` - changes animation's duration
- `data-sal-delay` - adds delay to animation
In **sal.js** you can easily change animation's options, by adding a proper `data` attribute:
- `data-sal-duration` - changes duration of the animation
- `data-sal-delay` - adds delay to the animation
- `data-sal-easing` - sets easing for the animation

For example:
```html
<div
data-sal="slide-up"
data-sal-delay='300'
data-sal-easing='ease-out-bounce'
data-sal-delay="300"
data-sal-easing="ease-out-bounce"
></div>
```

Library supports several animations:
The library supports several animations:
- `fade`
- `slide-up`
- `slide-down`
Expand All @@ -90,9 +92,9 @@ Library supports several animations:

| Property | Type | Description | Default |
|---------------------------|-------------|---------------|---------|
| `threshold` | Number | Percentage of element's area that needs to be visible to launch animation (see [docs](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/thresholds)) | 0.5 |
| `once` | Boolean | Defines if animation needs to be launched once | true |
| `disable` | Boolean | Flag for disabling animations | false |
| `threshold` | Number | Percentage of an element's area that needs to be visible to launch animation (see [docs](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/thresholds)) | `0.5` |
| `once` | Boolean | Defines if animation needs to be launched once | `true` |
| `disable` | Boolean | Flag for disabling animations | `false` |

You can set options during Sal's initialization, e.g.:

Expand All @@ -107,10 +109,10 @@ sal({

| Property | Type | Description | Default |
|---------------------------|-------------|---------------|---------|
| `selector` | String | Selector of element, which should be animated | [data-sal] |
| `animateClassName` | String | Class name which triggers animation | sal-animate |
| `disabledClassName` | String | Class name which defines disable state | sal-disabled |
| `rootMargin` | String | Corresponds to root's bounding box margin (see [docs](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin)) | 0% 50% |
| `selector` | String | Selector of the elements to be animated | `[data-sal]` |
| `animateClassName` | String | Class name which triggers animation | `sal-animate` |
| `disabledClassName` | String | Class name which defines the disabled state | `sal-disabled` |
| `rootMargin` | String | Corresponds to root's bounding box margin (see [docs](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin)) | `0% 50%` |

## API

Expand Down

0 comments on commit f2f72b9

Please sign in to comment.