Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Commit 8d01652

Browse files
committed
* Linting fix
* Including external module for interpolation for better maintability
1 parent f67377c commit 8d01652

File tree

4 files changed

+21
-27
lines changed

4 files changed

+21
-27
lines changed

package-lock.json

+3-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "es6-tween",
3-
"version": "3.4.0",
3+
"version": "3.5.0",
44
"description": "ES6 implementation of amazing tween.js",
55
"browser": "dist/Tween.min.js",
66
"cdn": "dist/Tween.min.js",
@@ -50,6 +50,6 @@
5050
"uglify-es": "latest"
5151
},
5252
"dependencies": {
53-
"intertween": "latest"
53+
"intertween": "0.0.14"
5454
}
5555
}

rollup.config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ const plugins = [
2020
}
2121
}),
2222
nodeResolve({
23-
main: true
23+
main: true,
24+
jsnext: true
2425
}),
2526
commonjs({
26-
include: ['./node_modules/intertween/index.js']
27+
include: ['node_modules/intertween/index.js']
2728
})
2829
]
2930

src/dist/Tween.js

+13-19
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import InterTween from 'intertween'
1010
import NodeCache from './NodeCache'
1111
import EventClass from './Event'
1212

13-
const defaultEasing = Easing.Linear.None
14-
1513
// Events list
1614
export const EVENT_UPDATE = 'update'
1715
export const EVENT_COMPLETE = 'complete'
@@ -38,15 +36,14 @@ class Tween extends EventClass {
3836
this.node = node
3937
if (typeof object === 'object') {
4038
object = this.object = NodeCache(node, object)
41-
this.object.node = node
4239
} else {
4340
this.object = object
4441
}
4542
}
4643
this._valuesEnd = null
4744

4845
this._duration = 1000
49-
this._easingFunction = defaultEasing
46+
this._easingFunction = Easing.Linear.None
5047

5148
this._startTime = 0
5249
this._delayTime = 0
@@ -173,10 +170,8 @@ class Tween extends EventClass {
173170
}
174171
}
175172

176-
this._valuesEnd = _valuesEnd = InterTween(object, _valuesEnd)
177-
178173
if (Renderer && this.node) {
179-
this.__render = new Renderer(this, _valuesEnd)
174+
this.__render = new Renderer(this, object, _valuesEnd)
180175
}
181176

182177
return this
@@ -186,13 +181,8 @@ class Tween extends EventClass {
186181
this._startTime = time !== undefined ? time : now()
187182
this._startTime += this._delayTime
188183

189-
this.render()
190-
this._rendered = true
191-
192184
add(this)
193185

194-
this.emit(EVENT_START, this.object)
195-
196186
this._isPlaying = true
197187

198188
return this
@@ -268,11 +258,13 @@ class Tween extends EventClass {
268258
object
269259
} = this
270260

271-
for (let property in _valuesEnd) {
272-
let end = _valuesEnd[property]
261+
let v0 = _valuesEnd(0)
273262

274-
if (typeof end === 'number' || typeof end === 'string') {
275-
object[property] = end(0)
263+
if (typeof v0 === 'object') {
264+
let isArr = Array.isArray(v0)
265+
for (let property in v0) {
266+
if (isArr) property *= 1
267+
object[property] = v0[property]
276268
}
277269
}
278270

@@ -313,12 +305,14 @@ class Tween extends EventClass {
313305
if (!_onStartCallbackFired) {
314306
if (!this._rendered) {
315307
this.render()
316-
317-
this.emit(EVENT_START, object)
318-
319308
this._rendered = true
309+
if (typeof _valuesEnd !== 'function') {
310+
this._valuesEnd = _valuesEnd = InterTween(object, _valuesEnd)
311+
}
320312
}
321313

314+
this.emit(EVENT_START, object)
315+
322316
this._onStartCallbackFired = true
323317
}
324318

0 commit comments

Comments
 (0)