@linorabolini/tween.js 25.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +484 -0
- package/dist/tween.amd.js +1441 -0
- package/dist/tween.cjs +1439 -0
- package/dist/tween.d.ts +727 -0
- package/dist/tween.esm.js +1421 -0
- package/dist/tween.umd.js +1445 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2010-2012 Tween.js authors.
|
|
4
|
+
|
|
5
|
+
Easing equations Copyright (c) 2001 Robert Penner http://robertpenner.com/easing/
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
# tween.js
|
|
2
|
+
|
|
3
|
+
JavaScript (TypeScript) tweening engine for easy animations, incorporating optimised Robert Penner's equations.
|
|
4
|
+
|
|
5
|
+
[![NPM Version][npm-image]][npm-url]
|
|
6
|
+
[![CDNJS][cdnjs-image]][cdnjs-url]
|
|
7
|
+
[![NPM Downloads][downloads-image]][downloads-url]
|
|
8
|
+
[![Build and Tests][ci-image]][ci-url]
|
|
9
|
+
|
|
10
|
+
More languages: [English](./README.md), [简体中文](./README_zh-CN.md)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
```html
|
|
15
|
+
<div id="box"></div>
|
|
16
|
+
|
|
17
|
+
<style>
|
|
18
|
+
#box {
|
|
19
|
+
background-color: deeppink;
|
|
20
|
+
width: 100px;
|
|
21
|
+
height: 100px;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
24
|
+
|
|
25
|
+
<script type="module">
|
|
26
|
+
import {Tween, Easing} from 'https://unpkg.com/@tweenjs/tween.js@23.1.3/dist/tween.esm.js'
|
|
27
|
+
|
|
28
|
+
const box = document.getElementById('box') // Get the element we want to animate.
|
|
29
|
+
|
|
30
|
+
const coords = {x: 0, y: 0} // Start at (0, 0)
|
|
31
|
+
|
|
32
|
+
const tween = new Tween(coords, false) // Create a new tween that modifies 'coords'.
|
|
33
|
+
.to({x: 300, y: 200}, 1000) // Move to (300, 200) in 1 second.
|
|
34
|
+
.easing(Easing.Quadratic.InOut) // Use an easing function to make the animation smooth.
|
|
35
|
+
.onUpdate(() => {
|
|
36
|
+
// Called after tween.js updates 'coords'.
|
|
37
|
+
// Move 'box' to the position described by 'coords' with a CSS translation.
|
|
38
|
+
box.style.setProperty('transform', 'translate(' + coords.x + 'px, ' + coords.y + 'px)')
|
|
39
|
+
})
|
|
40
|
+
.start() // Start the tween immediately.
|
|
41
|
+
|
|
42
|
+
// Setup the animation loop.
|
|
43
|
+
function animate(time) {
|
|
44
|
+
tween.update(time)
|
|
45
|
+
requestAnimationFrame(animate)
|
|
46
|
+
}
|
|
47
|
+
requestAnimationFrame(animate)
|
|
48
|
+
</script>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
[Try this example on CodePen](https://codepen.io/trusktr/pen/KKGaBVz?editors=1000)
|
|
52
|
+
|
|
53
|
+
# Features
|
|
54
|
+
|
|
55
|
+
- Does one thing only and does it well: tweens properties of an object
|
|
56
|
+
- Doesn't take care of CSS units (e.g. appending `px`)
|
|
57
|
+
- Doesn't interpolate colors
|
|
58
|
+
- Easing functions are reusable outside of Tween
|
|
59
|
+
- Can also use custom easing functions
|
|
60
|
+
- Doesn't make its own animation loop, making it flexible for integration into
|
|
61
|
+
any animation loop.
|
|
62
|
+
|
|
63
|
+
# Examples
|
|
64
|
+
|
|
65
|
+
<table>
|
|
66
|
+
<tr>
|
|
67
|
+
<td>
|
|
68
|
+
<a href="http://tweenjs.github.io/tween.js/examples/00_hello_world.html">
|
|
69
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/00_hello_world.png" alt="hello world" />
|
|
70
|
+
</a>
|
|
71
|
+
</td>
|
|
72
|
+
<td>
|
|
73
|
+
hello world<br />
|
|
74
|
+
(<a href="examples/00_hello_world.html">source</a>)
|
|
75
|
+
</td>
|
|
76
|
+
<td>
|
|
77
|
+
<a href="http://tweenjs.github.io/tween.js/examples/01_bars.html">
|
|
78
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/01_bars.png" alt="Bars" />
|
|
79
|
+
</a>
|
|
80
|
+
</td>
|
|
81
|
+
<td>
|
|
82
|
+
Bars<br />
|
|
83
|
+
(<a href="examples/01_bars.html">source</a>)
|
|
84
|
+
</td>
|
|
85
|
+
<tr>
|
|
86
|
+
</tr>
|
|
87
|
+
<td>
|
|
88
|
+
<a href="http://tweenjs.github.io/tween.js/examples/02_black_and_red.html">
|
|
89
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/02_black_and_red.png" alt="Black and red" />
|
|
90
|
+
</a>
|
|
91
|
+
</td>
|
|
92
|
+
<td>
|
|
93
|
+
Black and red<br />
|
|
94
|
+
(<a href="examples/02_black_and_red.html">source</a>)
|
|
95
|
+
</td>
|
|
96
|
+
<td>
|
|
97
|
+
<a href="http://tweenjs.github.io/tween.js/examples/03_graphs.html">
|
|
98
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/03_graphs.png" alt="Graphs" />
|
|
99
|
+
</a>
|
|
100
|
+
</td>
|
|
101
|
+
<td>
|
|
102
|
+
Graphs<br />
|
|
103
|
+
(<a href="examples/03_graphs.html">source</a>)
|
|
104
|
+
</td>
|
|
105
|
+
</tr>
|
|
106
|
+
<tr>
|
|
107
|
+
<td>
|
|
108
|
+
<a href="http://tweenjs.github.io/tween.js/examples/04_simplest.html">
|
|
109
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/04_simplest.png" alt="Simplest possible example" />
|
|
110
|
+
</a>
|
|
111
|
+
</td>
|
|
112
|
+
<td>
|
|
113
|
+
Simplest possible example<br />
|
|
114
|
+
(<a href="examples/04_simplest.html">source</a>)
|
|
115
|
+
</td>
|
|
116
|
+
<td>
|
|
117
|
+
<a href="http://tweenjs.github.io/tween.js/examples/05_video_and_time.html">
|
|
118
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/06_video_and_time.png" alt="Video and time" />
|
|
119
|
+
</a>
|
|
120
|
+
</td>
|
|
121
|
+
<td>
|
|
122
|
+
Video and time<br />
|
|
123
|
+
(<a href="examples/05_video_and_time.html">source</a>)
|
|
124
|
+
</td>
|
|
125
|
+
</tr>
|
|
126
|
+
<tr>
|
|
127
|
+
<td>
|
|
128
|
+
<a href="http://tweenjs.github.io/tween.js/examples/06_array_interpolation.html">
|
|
129
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/03_graphs.png" alt="Array interpolation" />
|
|
130
|
+
</a>
|
|
131
|
+
</td>
|
|
132
|
+
<td>
|
|
133
|
+
Array interpolation<br />
|
|
134
|
+
(<a href="examples/06_array_interpolation.html">source</a>)
|
|
135
|
+
</td>
|
|
136
|
+
<td>
|
|
137
|
+
<a href="http://tweenjs.github.io/tween.js/examples/07_dynamic_to.html">
|
|
138
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/07_dynamic_to.png" alt="Dynamic to, object" />
|
|
139
|
+
</a>
|
|
140
|
+
</td>
|
|
141
|
+
<td>
|
|
142
|
+
Dynamic to, object<br />
|
|
143
|
+
(<a href="examples/07_dynamic_to.html">source</a>)
|
|
144
|
+
</td>
|
|
145
|
+
</tr>
|
|
146
|
+
<tr>
|
|
147
|
+
<td>
|
|
148
|
+
<a href="http://tweenjs.github.io/tween.js/examples/07a_dynamic_to_two_array_values.html">
|
|
149
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/07a_dynamic_to.png" alt="Dynamic to, interpolation array" />
|
|
150
|
+
</a>
|
|
151
|
+
</td>
|
|
152
|
+
<td>
|
|
153
|
+
Dynamic to, interpolation array<br />
|
|
154
|
+
(<a href="examples/07a_dynamic_to_two_array_values.html">source</a>)
|
|
155
|
+
</td>
|
|
156
|
+
<td>
|
|
157
|
+
<a href="http://tweenjs.github.io/tween.js/examples/07b_dynamic_to_an_array_of_values.html">
|
|
158
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/07b_dynamic_to.png" alt="Dynamic to, large interpolation array" />
|
|
159
|
+
</a>
|
|
160
|
+
</td>
|
|
161
|
+
<td>
|
|
162
|
+
Dynamic to, large interpolation array<br />
|
|
163
|
+
(<a href="examples/07b_dynamic_to_an_array_of_values.html">source</a>)
|
|
164
|
+
</td>
|
|
165
|
+
</tr>
|
|
166
|
+
<tr>
|
|
167
|
+
<td>
|
|
168
|
+
<a href="http://tweenjs.github.io/tween.js/examples/08_repeat.html">
|
|
169
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/08_repeat.png" alt="Repeat" />
|
|
170
|
+
</a>
|
|
171
|
+
</td>
|
|
172
|
+
<td>
|
|
173
|
+
Repeat<br />
|
|
174
|
+
(<a href="examples/08_repeat.html">source</a>)
|
|
175
|
+
</td>
|
|
176
|
+
<td>
|
|
177
|
+
<a href="http://tweenjs.github.io/tween.js/examples/09_relative_values.html">
|
|
178
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/09_relative.png" alt="Relative values" />
|
|
179
|
+
</a>
|
|
180
|
+
</td>
|
|
181
|
+
<td>
|
|
182
|
+
Relative values<br />
|
|
183
|
+
(<a href="examples/09_relative_values.html">source</a>)
|
|
184
|
+
</td>
|
|
185
|
+
</tr>
|
|
186
|
+
<tr>
|
|
187
|
+
<td>
|
|
188
|
+
<a href="http://tweenjs.github.io/tween.js/examples/10_yoyo.html">
|
|
189
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/10_yoyo.png" alt="Yoyo" />
|
|
190
|
+
</a>
|
|
191
|
+
</td>
|
|
192
|
+
<td>
|
|
193
|
+
Yoyo<br />
|
|
194
|
+
(<a href="examples/10_yoyo.html">source</a>)
|
|
195
|
+
</td>
|
|
196
|
+
<td>
|
|
197
|
+
<a href="http://tweenjs.github.io/tween.js/examples/11_stop_all_chained_tweens.html">
|
|
198
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/11_stop_all_chained_tweens.png" alt="Stop all chained tweens" />
|
|
199
|
+
</a>
|
|
200
|
+
</td>
|
|
201
|
+
<td>
|
|
202
|
+
Stop all chained tweens<br />
|
|
203
|
+
(<a href="examples/11_stop_all_chained_tweens.html">source</a>)
|
|
204
|
+
</td>
|
|
205
|
+
</tr>
|
|
206
|
+
<tr>
|
|
207
|
+
<td>
|
|
208
|
+
<a href="http://tweenjs.github.io/tween.js/examples/12_graphs_custom_functions.html">
|
|
209
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/03_graphs.png" alt="Custom functions" />
|
|
210
|
+
</a>
|
|
211
|
+
</td>
|
|
212
|
+
<td>
|
|
213
|
+
Custom functions<br />
|
|
214
|
+
(<a href="examples/12_graphs_custom_functions.html">source</a>)
|
|
215
|
+
</td>
|
|
216
|
+
<td>
|
|
217
|
+
<a href="http://tweenjs.github.io/tween.js/examples/13_relative_start_time.html">
|
|
218
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/13_relative_start_time.png" alt="Relative start time" />
|
|
219
|
+
</a>
|
|
220
|
+
</td>
|
|
221
|
+
<td>
|
|
222
|
+
Relative start time<br />
|
|
223
|
+
(<a href="examples/13_relative_start_time.html">source</a>)
|
|
224
|
+
</td>
|
|
225
|
+
</tr>
|
|
226
|
+
<tr>
|
|
227
|
+
<td>
|
|
228
|
+
<a href="http://tweenjs.github.io/tween.js/examples/14_pause_tween.html">
|
|
229
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/14_pause_tween.png" alt="Pause tween" />
|
|
230
|
+
</a>
|
|
231
|
+
</td>
|
|
232
|
+
<td>
|
|
233
|
+
Pause tween<br />
|
|
234
|
+
(<a href="examples/14_pause_tween.html">source</a>)
|
|
235
|
+
</td>
|
|
236
|
+
<td>
|
|
237
|
+
<a href="http://tweenjs.github.io/tween.js/examples/15_complex_properties.html">
|
|
238
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/15_complex_properties.png" alt="Complex properties" />
|
|
239
|
+
</a>
|
|
240
|
+
</td>
|
|
241
|
+
<td>
|
|
242
|
+
Complex properties<br />
|
|
243
|
+
(<a href="examples/15_complex_properties.html">source</a>)
|
|
244
|
+
</td>
|
|
245
|
+
</tr>
|
|
246
|
+
<tr>
|
|
247
|
+
<td>
|
|
248
|
+
<a href="http://tweenjs.github.io/tween.js/examples/16_animate_an_array_of_values.html">
|
|
249
|
+
<img width="100" height="50" src="https://tweenjs.github.io/tween.js/assets/examples/16_animate_an_array_of_values.png" alt="Animate an array of values" />
|
|
250
|
+
</a>
|
|
251
|
+
</td>
|
|
252
|
+
<td>
|
|
253
|
+
Animate an array of values<br />
|
|
254
|
+
(<a href="examples/16_animate_an_array_of_values.html">source</a>)
|
|
255
|
+
</td>
|
|
256
|
+
</tr>
|
|
257
|
+
</table>
|
|
258
|
+
|
|
259
|
+
# Installation
|
|
260
|
+
|
|
261
|
+
The recommended method is to use `import` syntax. Here we've listed various
|
|
262
|
+
install methods starting roughly with the most recommended first and least
|
|
263
|
+
desirable last. Evaluate all of the following methods to pick what is most
|
|
264
|
+
suitable for your project.
|
|
265
|
+
|
|
266
|
+
## With `npm install` and `import` from `node_modules`
|
|
267
|
+
|
|
268
|
+
You can add tween.js as an npm dependency:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
npm install @tweenjs/tween.js
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Without a build tool
|
|
275
|
+
|
|
276
|
+
#### Installed locally
|
|
277
|
+
|
|
278
|
+
You can import from `node_modules` if you serve `node_modules` as part of your
|
|
279
|
+
website, using a standard `importmap` script tag. First, assuming `node_modules`
|
|
280
|
+
is at the root of your website, you can write an import map like so in your HTML
|
|
281
|
+
file:
|
|
282
|
+
|
|
283
|
+
```html
|
|
284
|
+
<script type="importmap">
|
|
285
|
+
{
|
|
286
|
+
"imports": {
|
|
287
|
+
"@tweenjs/tween.js": "/node_modules/@tweenjs/tween.js/dist/tween.esm.js"
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
</script>
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Now in any of your module scripts you can import Tween.js by its package name:
|
|
294
|
+
|
|
295
|
+
```html
|
|
296
|
+
<script type="module">
|
|
297
|
+
import {Tween} from '@tweenjs/tween.js'
|
|
298
|
+
</script>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
#### Import from CDN
|
|
302
|
+
|
|
303
|
+
Note that, without the `importmap`, you can import directly from a CDN as with the first example above, like so:
|
|
304
|
+
|
|
305
|
+
```html
|
|
306
|
+
<script type="module">
|
|
307
|
+
import {Tween} from 'https://unpkg.com/browse/@tweenjs/tween.js@23.1.3/dist/tween.esm.js'
|
|
308
|
+
</script>
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
You can also link your `importmap` to the CDN instead of a local `node_modules` folder, if you prefer that:
|
|
312
|
+
|
|
313
|
+
```html
|
|
314
|
+
<script type="importmap">
|
|
315
|
+
{
|
|
316
|
+
"imports": {
|
|
317
|
+
"@tweenjs/tween.js": "https://unpkg.com/browse/@tweenjs/tween.js@23.1.3/dist/tween.esm.js"
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
</script>
|
|
321
|
+
|
|
322
|
+
<script type="module">
|
|
323
|
+
import {Tween} from '@tweenjs/tween.js'
|
|
324
|
+
</script>
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### With a build tool
|
|
328
|
+
|
|
329
|
+
If you are using [Node.js](https://nodejs.org/),
|
|
330
|
+
[Parcel](https://parceljs.org/), [Webpack](https://webpack.js.org/),
|
|
331
|
+
[Rollup](https://rollupjs.org/), [Vite](https://vitejs.dev/), or another build
|
|
332
|
+
tool, then you can install `@tweenjs/tween.js` with `npm install
|
|
333
|
+
@tweenjs/tween.js`, and `import` the library into your JavaScript (or
|
|
334
|
+
TypeScript) file, and the build tool will know how to find the source code from
|
|
335
|
+
`node_modules` without needing to create an `importmap` script:
|
|
336
|
+
|
|
337
|
+
```javascript
|
|
338
|
+
import * as TWEEN from '@tweenjs/tween.js'
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
However, note that this approach requires always running a build tool for your
|
|
342
|
+
app to work, while the `importmap` approach will simply work without any build
|
|
343
|
+
tools as a simple static HTML site.
|
|
344
|
+
|
|
345
|
+
## Manual build
|
|
346
|
+
|
|
347
|
+
Another approach is to download the source code with git, manually build the
|
|
348
|
+
library, then place the output in your project. Node.js is required for this.
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
git clone https://github.com/tweenjs/tween.js
|
|
352
|
+
cd tween.js
|
|
353
|
+
npm install
|
|
354
|
+
npm run build
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
This will create some builds in the `dist` directory. There are currently two different builds of the library:
|
|
358
|
+
|
|
359
|
+
- ES6 Module in `/dist/tween.esm.js` (recommended)
|
|
360
|
+
- UMD in `/dist/tween.umd.js` (deprecated, will be removed in a future major version)
|
|
361
|
+
|
|
362
|
+
You are now able to copy one of those two files into your project, and use like this (recommended):
|
|
363
|
+
|
|
364
|
+
```html
|
|
365
|
+
<script type="module">
|
|
366
|
+
import {Tween} from 'path/to/tween.esm.js'
|
|
367
|
+
</script>
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
or (deprecated, to be removed in future major):
|
|
371
|
+
|
|
372
|
+
```html
|
|
373
|
+
<script src="path/to/tween.umd.js"></script>
|
|
374
|
+
<script>
|
|
375
|
+
const {Tween} = TWEEN
|
|
376
|
+
</script>
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
where `path/to` is replaced with the location where you placed the file.
|
|
380
|
+
|
|
381
|
+
> [!Note]
|
|
382
|
+
> You can also download these files from unpkg, for example here:
|
|
383
|
+
> https://unpkg.com/browse/@tweenjs/tween.js@23.1.3/dist/
|
|
384
|
+
|
|
385
|
+
## Global variable from CDN (deprecated)
|
|
386
|
+
|
|
387
|
+
> [!Note]
|
|
388
|
+
> This method is deprecated and will be removed in a future major version!
|
|
389
|
+
|
|
390
|
+
Install a global `TWEEN` variable from a content-delivery network (CDN) using the UMD file.
|
|
391
|
+
|
|
392
|
+
From cdnjs:
|
|
393
|
+
|
|
394
|
+
```html
|
|
395
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/tween.js/23.1.3/tween.umd.js"></script>
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
Or from unpkg.com:
|
|
399
|
+
|
|
400
|
+
```html
|
|
401
|
+
<script src="https://unpkg.com/@tweenjs/tween.js@^23.1.3/dist/tween.umd.js"></script>
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Then use the `TWEEN` variable in any script:
|
|
405
|
+
|
|
406
|
+
```html
|
|
407
|
+
<script>
|
|
408
|
+
const {Tween, Easing, Group /*, ...*/} = TWEEN
|
|
409
|
+
|
|
410
|
+
const tween = new Tween(someObject)
|
|
411
|
+
// ...
|
|
412
|
+
</script>
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
> [!Note]
|
|
416
|
+
> unpkg.com supports a semver version in the URL, where the `^` in the
|
|
417
|
+
> URL tells unpkg to give you the latest version 20.x.x.
|
|
418
|
+
|
|
419
|
+
## CommonJS (deprecated)
|
|
420
|
+
|
|
421
|
+
Skip this section if you don't know what CommonJS is!
|
|
422
|
+
|
|
423
|
+
> [!Note]
|
|
424
|
+
> This method is deprecated and will be removed in a future major version!
|
|
425
|
+
|
|
426
|
+
Any of the above methods work in older systems that still use CommonJS. Repeat
|
|
427
|
+
any of the above methods but using `dist/tween.cjs` instead of
|
|
428
|
+
`dist/tween.esm.js` or `dist/tween.umd.js`.
|
|
429
|
+
|
|
430
|
+
# Documentation
|
|
431
|
+
|
|
432
|
+
- [User guide](./docs/user_guide.md)
|
|
433
|
+
- [Contributor guide](./docs/contributor_guide.md)
|
|
434
|
+
- [Tutorial](https://web.archive.org/web/20220601192930/http://learningthreejs.com/blog/2011/08/17/tweenjs-for-smooth-animation/) using tween.js with three.js
|
|
435
|
+
- Also: [libtween](https://github.com/jsm174/libtween), a port of tween.js to C by [jsm174](https://github.com/jsm174)
|
|
436
|
+
|
|
437
|
+
# Tests
|
|
438
|
+
|
|
439
|
+
You need to install `npm` first--this comes with node.js, so install that one first. Then, cd to `tween.js`'s (or wherever you cloned the repo) directory and run:
|
|
440
|
+
|
|
441
|
+
```bash
|
|
442
|
+
npm install
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
To run the tests run:
|
|
446
|
+
|
|
447
|
+
```bash
|
|
448
|
+
npm test
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
If you want to add any feature or change existing features, you _must_ run the
|
|
452
|
+
tests to make sure you didn't break anything else. Any pull request (PR) needs
|
|
453
|
+
to have updated passing tests for feature changes (or new passing tests for new
|
|
454
|
+
features or fixes) in `src/tests.ts` to be accepted. See
|
|
455
|
+
[contributing](CONTRIBUTING.md) for more information.
|
|
456
|
+
|
|
457
|
+
# People
|
|
458
|
+
|
|
459
|
+
Maintainers: [Joe Pea (@trusktr)](https://github.com/trusktr).
|
|
460
|
+
|
|
461
|
+
[All contributors](http://github.com/tweenjs/tween.js/contributors).
|
|
462
|
+
|
|
463
|
+
# Projects using tween.js
|
|
464
|
+
|
|
465
|
+
[<img src="./assets/projects/11_lume.jpg" width="100" alt="Lume" />](https://lume.io)
|
|
466
|
+
[](https://aframe.io)
|
|
467
|
+
[](http://www.moma.org/interactives/exhibitions/2012/inventingabstraction/)
|
|
468
|
+
[](http://www.chromeweblab.com/)
|
|
469
|
+
[](http://5013.es/toys/macchina)
|
|
470
|
+
[](http://egraether.com/mine3d/)
|
|
471
|
+
[](http://ro.me)
|
|
472
|
+
[](http://data-arts.appspot.com/globe)
|
|
473
|
+
[](http://www.androidify.com/)
|
|
474
|
+
[](http://thewildernessdowntown.com/)
|
|
475
|
+
[](http://dejavis.org/linechart)
|
|
476
|
+
|
|
477
|
+
[npm-image]: https://img.shields.io/npm/v/@tweenjs/tween.js.svg
|
|
478
|
+
[npm-url]: https://npmjs.org/package/@tweenjs/tween.js
|
|
479
|
+
[downloads-image]: https://img.shields.io/npm/dm/@tweenjs/tween.js.svg
|
|
480
|
+
[downloads-url]: https://npmjs.org/package/@tweenjs/tween.js
|
|
481
|
+
[ci-image]: https://github.com/tweenjs/tween.js/workflows/build%20and%20tests/badge.svg?branch=master
|
|
482
|
+
[ci-url]: https://github.com/tweenjs/tween.js/actions
|
|
483
|
+
[cdnjs-image]: https://img.shields.io/cdnjs/v/tween.js.svg
|
|
484
|
+
[cdnjs-url]: https://cdnjs.com/libraries/tween.js
|