Skip to content

Commit 8a821f3

Browse files
committed
2 parents 4fb070c + 1ccf0b6 commit 8a821f3

29 files changed

+3492
-2668
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ after_success:
1515
deploy:
1616
provider: surge
1717
project: ./examples/
18-
domain: betweenjs.surge.sh
18+
domain: betweenjs.js.org
1919
on:
2020
all_branches: true

README.md

Lines changed: 62 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,56 @@
44

55
> Lightweight JavaScript (ES6) tweening library.
66
7-
![](https://travis-ci.org/sasha240100/between.js.svg?branch=master)
8-
![](https://img.shields.io/npm/v/between.js.svg)
7+
[![](https://travis-ci.org/sasha240100/between.js.svg?branch=master)](https://travis-ci.org/sasha240100/between.js)
8+
[![](https://img.shields.io/npm/v/between.js.svg)](https://www.npmjs.com/package/between.js)
9+
10+
[![NPM](https://nodei.co/npm/between.js.png)](https://nodei.co/npm/between.js/)
911

1012
**EXAMPLES**
11-
* [Examples collection](http://betweenjs.surge.sh/)
13+
* [Examples collection](http://between.js.org/)
1214

1315
**DOCUMENTATION**
14-
15-
* [Purpose](#purpose)
16-
* [Installation](#install-with-npm)
17-
* [Basic usage](#basic-usage)
18-
* [Events](#events)
19-
* [Different values](#different-values)
20-
* [Looping](#looping)
21-
* [Easing](#easing)
22-
* [Color](#color)
23-
* [Mixed examples](#mixed-examples)
24-
25-
## Purpose
16+
- [Purpose](#purpose)
17+
- [Install](#install)
18+
- [With npm](#with-npm)
19+
- [Or fetch from CDN](#or-fetch-from-cdn)
20+
- [Basic usage](#basic-usage)
21+
- [Module](#module)
22+
- [Or in HTML:](#or-in-html)
23+
- [API](#api)
24+
- [Events](#events)
25+
- [Different values](#different-values)
26+
- [Looping](#looping)
27+
- [Easing](#easing)
28+
- [Color](#color)
29+
- [Mixed examples](#mixed-examples)
30+
31+
# Purpose
2632

2733
Make tweening usage convenient and powerful. There are certain things that we were following while developed this library, we wanted to make it:
2834

29-
- The most **lightweight** :snowflake: JS Tweening library.
30-
> The library is only `8.3 Kb`
31-
- The most **performant** :zap: JS Tweening library.
35+
- **Lightweight** :snowflake: JS Tweening library.
36+
> The library is only `8.3 Kb (3Kb gzip)`
37+
- **Performant** :zap: JS Tweening library.
3238
> It uses optimization patterns to speed up & smooth animation.
33-
- The most **modern** :gem: JS Tweening library
39+
- **Modern** :gem: JS Tweening library
3440
> The library is written in `ES6`, compiled to ES5 for global browsers support and provides `ES6 API`.
3541
36-
## Install with npm
42+
# Install
43+
## With npm
3744

3845
```
3946
$ npm install between.js
4047
```
4148

42-
## Basic usage
49+
## Or fetch from CDN
50+
51+
```
52+
<script src="https://rawgit.com/sasha240100/between.js/master/build/between.js"></script>
53+
```
4354

55+
# Basic usage
56+
## Module
4457
```javascript
4558
import Between from 'between.js';
4659

@@ -51,8 +64,7 @@ new Between(1, 10).time(1000)
5164
});
5265
```
5366

54-
55-
Or in HTML:
67+
## Or in HTML:
5668

5769
```html
5870
<script src="./path/to/between.js"></script>
@@ -78,11 +90,18 @@ new Between(
7890
.loop([String] mode, [?Number] repeatTimes) // Set loop mode, if "repeatTimes" is falsy, treats as "endless"
7991
.easing([Function] easing) // Set easing function
8092
.on([String] eventName, [Function] callback) // Add event listener
93+
.pause() // Pauses
94+
.play() // Resumes
95+
96+
// Getters
97+
.isPaused // returns true if paused
8198
```
8299
100+
101+
83102
> There is no need to "start" the tween. It is executed immediately once it was created.
84103
85-
## Events
104+
# Events
86105
87106
```javascript
88107
import Between from 'between.js';
@@ -94,12 +113,18 @@ new Between(1, 10).time(1000)
94113
.on('start', (value) => {
95114
console.log(value);
96115
})
116+
.on('pause', (value) => {
117+
console.log(value);
118+
})
119+
.on('play', (value) => {
120+
console.log(value);
121+
})
97122
.on('complete', (value) => {
98123
console.log(value);
99124
});
100125
```
101126
102-
## Different values
127+
# Different values
103128
104129
* Numbers
105130
* Arrays
@@ -116,7 +141,7 @@ new Between(1, 10).time(1000)
116141
});
117142
```
118143
119-
[Example](http://betweenjs.surge.sh/basic.html)
144+
[Example](http://between.js.org/basic.html)
120145
121146
**Arrays**
122147
@@ -129,7 +154,7 @@ new Between([1, 5], [10, 10]).time(1000)
129154
});
130155
```
131156
132-
[Example](http://betweenjs.surge.sh/arrays.html)
157+
[Example](http://between.js.org/arrays.html)
133158
134159
**Objects**
135160
@@ -142,9 +167,9 @@ new Between({x: 2, y: 3, z: 4}, {x: 4, y: 6, z: 10}).time(1000)
142167
});
143168
```
144169
145-
[Example](http://betweenjs.surge.sh/objects.html)
170+
[Example](http://between.js.org/objects.html)
146171
147-
## Looping
172+
# Looping
148173
149174
Repeat `N` times
150175
@@ -159,7 +184,7 @@ new Between(1, 10).time(4000)
159184
});
160185
```
161186
162-
[Example](http://betweenjs.surge.sh/loop-repeat.html)
187+
[Example](http://between.js.org/loop-repeat.html)
163188
164189
Repeat endless
165190
@@ -173,7 +198,7 @@ new Between(1, 10).time(4000)
173198
});
174199
```
175200
176-
[Example](http://betweenjs.surge.sh/loop-repeat.html)
201+
[Example](http://between.js.org/loop-repeat.html)
177202
178203
Bounce `N` times
179204
@@ -188,9 +213,9 @@ new Between(1, 10).time(4000)
188213
});
189214
```
190215
191-
[Example](http://betweenjs.surge.sh/loop-bounce.html)
216+
[Example](http://between.js.org/loop-bounce.html)
192217
193-
## Easing
218+
# Easing
194219
195220
```javascript
196221
import Between from 'between.js';
@@ -205,13 +230,13 @@ new Between(1, 10).time(4000)
205230
});
206231
```
207232
208-
[Example](http://betweenjs.surge.sh/easing.html)
233+
[Example](http://between.js.org/easing.html)
209234
210235
<img src=".gitbook/assets/screen-shot-2018-07-29-at-13.25.52.png" height="400">
211236
212237
[easing-functions npm](https://www.npmjs.com/package/easing-functions)
213238
214-
## Color
239+
# Color
215240
216241
Color types:
217242
@@ -232,7 +257,7 @@ new Between('red', 'rgb(255,40,30)').time(4000)
232257
});
233258
```
234259
235-
[Example](http://betweenjs.surge.sh/color-plugin.html)
260+
[Example](http://between.js.org/color-plugin.html)
236261
237262
Or in HTML:
238263
@@ -241,7 +266,7 @@ Or in HTML:
241266
<script src="./path/to/dom-color.between.js"></script>
242267
```
243268
244-
## Mixed examples
269+
# Mixed examples
245270
246271
```javascript
247272
import Between from 'between.js';

build/between.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/arrays.html

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ <h5><a href="/">All examples</a></h5>
2222
<h5 class="demo">Demo &nbsp;&nbsp; <span onclick="window.location.reload()"><img height="16" src="./img/replay.png"></span></h5>
2323

2424
<hr>
25-
<h5 data-value>value: 1, 5</h5>
25+
<h5 data-value>value: &nbsp;&nbsp; [1, &nbsp;&nbsp;5]</h5>
2626
<h5 data-state>state: started</h5>
2727
<h5 data-time>localTime[ms]: 0</h5>
2828
</div>
@@ -34,14 +34,21 @@ <h5 data-time>localTime[ms]: 0</h5>
3434
const state = document.querySelector('[data-state]');
3535
const time = document.querySelector('[data-time]');
3636

37-
const a = new Between([1, 5], [10, 10]).time(5000).on('update', (v, {localTime}) => {
38-
value.innerHTML = `value: &nbsp;&nbsp; [${v.map(a => a.toFixed(2)).join(',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;')}]`;
39-
time.innerText = `localTime[ms]: ${localTime}`;
40-
}).on('start', () => {
41-
state.innerText = 'state: running';
42-
}).on('complete', () => {
43-
state.innerText = 'state: complete';
44-
});
37+
function createTween() {
38+
new Between([1, 5], [10, 10])
39+
.time(5000)
40+
.on('update', (v, {localTime}) => {
41+
value.innerHTML =
42+
`value: &nbsp;&nbsp; [${v.map(a => a.toFixed(2)).join(',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;')}]`;
43+
time.innerText = `localTime[ms]: ${localTime}`;
44+
}).on('start', () => {
45+
state.innerText = 'state: running';
46+
}).on('complete', () => {
47+
state.innerText = 'state: complete';
48+
});
49+
}
50+
51+
window.onload = () => setTimeout(createTween, 2000);
4552
</script>
4653
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js" charset="utf-8"></script>
4754
<script src="./js/script.js" charset="utf-8"></script>

examples/basic.html

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,19 @@ <h5 data-state>state: started</h5>
3232
const value = document.querySelector('[data-value]');
3333
const state = document.querySelector('[data-state]');
3434

35-
new Between(1, 10).time(1000).on('update', v => {
36-
value.innerText = `value: ${v.toFixed(2)}`;
37-
}).on('start', () => {
38-
state.innerText = 'state: running';
39-
}).on('complete', () => {
40-
state.innerText = 'state: complete';
41-
});
35+
function createTween() {
36+
new Between(1, 10)
37+
.time(1000)
38+
.on('update', v => {
39+
value.innerText = `value: ${v.toFixed(2)}`;
40+
}).on('start', () => {
41+
state.innerText = 'state: running';
42+
}).on('complete', () => {
43+
state.innerText = 'state: complete';
44+
});
45+
}
46+
47+
window.onload = () => setTimeout(createTween, 2000);
4248
</script>
4349
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js" charset="utf-8"></script>
4450
<script src="./js/script.js" charset="utf-8"></script>

examples/color-plugin.html

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,20 @@ <h5 data-state>state: started</h5>
3232
const value = document.querySelector('[data-value]');
3333
const state = document.querySelector('[data-state]');
3434

35-
new Between('white', 'rgb(255, 0, 0)').time(1000).on('update', v => {
36-
value.innerText = `Color: ${v}`;
37-
value.style.color = v;
38-
}).on('start', () => {
39-
state.innerText = 'state: running';
40-
}).on('complete', () => {
41-
state.innerText = 'state: complete';
42-
});
35+
function createTween() {
36+
new Between('green', 'rgb(255, 0, 0)')
37+
.time(3000)
38+
.on('update', v => {
39+
value.innerText = `Color: ${v}`;
40+
value.style.color = v;
41+
}).on('start', () => {
42+
state.innerText = 'state: running';
43+
}).on('complete', () => {
44+
state.innerText = 'state: complete';
45+
});
46+
}
47+
48+
window.onload = () => setTimeout(createTween, 2000);
4349
</script>
4450
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js" charset="utf-8"></script>
4551
<script src="./js/script.js" charset="utf-8"></script>

examples/compare.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ <h5 data-state style="padding-top: 20px;">state: started</h5>
2828
</div>
2929

3030
<script src="../build/between.js" charset="utf-8"></script>
31-
<script src="https://cdnjs.cloudflare.com/ajax/libs/tween.js/17.2.0/Tween.min.js" charset="utf-8"></script>
3231
<script data-example-code>
3332
const element = document.querySelector('#move');
3433
const state = document.querySelector('[data-state]');

examples/easing-sinus.html

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,20 @@ <h5 data-state>state: started</h5>
3232
const value = document.querySelector('[data-value]');
3333
const state = document.querySelector('[data-state]');
3434

35-
new Between(1, 10).time(5000).easing(Between.Easing.Bounce.In)
36-
.on('update', v => {
37-
value.innerText = `value: ${v.toFixed(2)}`;
38-
}).on('start', () => {
39-
state.innerText = 'state: running';
40-
}).on('complete', () => {
41-
state.innerText = 'state: complete';
42-
});
35+
function createTween() {
36+
new Between(1, 10)
37+
.time(5000)
38+
.easing(Between.Easing.Bounce.In) // Set easing mode
39+
.on('update', v => {
40+
value.innerText = `value: ${v.toFixed(2)}`;
41+
}).on('start', () => {
42+
state.innerText = 'state: running';
43+
}).on('complete', () => {
44+
state.innerText = 'state: complete';
45+
});
46+
}
47+
48+
window.onload = () => setTimeout(createTween, 2000);
4349
</script>
4450
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js" charset="utf-8"></script>
4551
<script src="./js/script.js" charset="utf-8"></script>

examples/easing.html

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,20 @@ <h5 data-state>state: started</h5>
3232
const value = document.querySelector('[data-value]');
3333
const state = document.querySelector('[data-state]');
3434

35-
new Between(1, 10).time(5000).easing(Between.Easing.Cubic.InOut)
36-
.on('update', v => {
37-
value.innerText = `value: ${v.toFixed(2)}`;
38-
}).on('start', () => {
39-
state.innerText = 'state: running';
40-
}).on('complete', () => {
41-
state.innerText = 'state: complete';
42-
});
35+
function createTween() {
36+
new Between(1, 10)
37+
.time(5000)
38+
.easing(Between.Easing.Cubic.InOut) // Set easing mode
39+
.on('update', v => {
40+
value.innerText = `value: ${v.toFixed(2)}`;
41+
}).on('start', () => {
42+
state.innerText = 'state: running';
43+
}).on('complete', () => {
44+
state.innerText = 'state: complete';
45+
});
46+
}
47+
48+
window.onload = () => setTimeout(createTween, 2000);
4349
</script>
4450
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js" charset="utf-8"></script>
4551
<script src="./js/script.js" charset="utf-8"></script>

examples/img/playpause.png

5.13 KB
Loading

0 commit comments

Comments
 (0)