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

Commit 9a54071

Browse files
committed
performance boost
1 parent fdc4ac8 commit 9a54071

File tree

3 files changed

+43
-39
lines changed

3 files changed

+43
-39
lines changed

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"eslint.enable": true,
3+
"eslint.autoFixOnSave": true,
34
"eslint.packageManager": "npm",
45
"prettier.requireConfig": true
56
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "es6-tween",
3-
"version": "5.5.9",
3+
"version": "5.5.10",
44
"description": "ES6 implementation of amazing tween.js",
55
"browser": "bundled/Tween.min.js",
66
"cdn": "bundled/Tween.min.js",

src/Tween.js

+41-38
Original file line numberDiff line numberDiff line change
@@ -402,52 +402,55 @@ class Tween {
402402
_valuesEnd = this._valuesEnd = InitialValues(node, object)
403403
}
404404
}
405-
for (const property in _valuesEnd) {
406-
let start = object && object[property] && deepCopy(object[property])
407-
let end = _valuesEnd[property]
408-
if (Plugins[property] && Plugins[property].init) {
409-
Plugins[property].init.call(this, start, end, property, object)
410-
if (start === undefined && _valuesStart[property]) {
411-
start = _valuesStart[property]
405+
if (!_valuesStart.processed) {
406+
for (const property in _valuesEnd) {
407+
let start = object && object[property] && deepCopy(object[property])
408+
let end = _valuesEnd[property]
409+
if (Plugins[property] && Plugins[property].init) {
410+
Plugins[property].init.call(this, start, end, property, object)
411+
if (start === undefined && _valuesStart[property]) {
412+
start = _valuesStart[property]
413+
}
414+
if (Plugins[property].skipProcess) {
415+
continue
416+
}
412417
}
413-
if (Plugins[property].skipProcess) {
418+
if (
419+
(typeof start === 'number' && isNaN(start)) ||
420+
start === null ||
421+
end === null ||
422+
start === false ||
423+
end === false ||
424+
start === undefined ||
425+
end === undefined ||
426+
start === end
427+
) {
414428
continue
415429
}
416-
}
417-
if (
418-
(typeof start === 'number' && isNaN(start)) ||
419-
start === null ||
420-
end === null ||
421-
start === false ||
422-
end === false ||
423-
start === undefined ||
424-
end === undefined ||
425-
start === end
426-
) {
427-
continue
428-
}
429-
_valuesStart[property] = start
430-
if (Array.isArray(end)) {
431-
if (!Array.isArray(start)) {
432-
end.unshift(start)
433-
for (let i = 0, len = end.length; i < len; i++) {
434-
if (typeof end[i] === 'string') {
435-
end[i] = decomposeString(end[i])
430+
_valuesStart[property] = start
431+
if (Array.isArray(end)) {
432+
if (!Array.isArray(start)) {
433+
end.unshift(start)
434+
for (let i = 0, len = end.length; i < len; i++) {
435+
if (typeof end[i] === 'string') {
436+
end[i] = decomposeString(end[i])
437+
}
436438
}
437-
}
438-
} else {
439-
if (end.isString && object[property].isString && !start.isString) {
440-
start.isString = true
441439
} else {
442-
decompose(property, object, _valuesStart, _valuesEnd)
440+
if (end.isString && object[property].isString && !start.isString) {
441+
start.isString = true
442+
} else {
443+
decompose(property, object, _valuesStart, _valuesEnd)
444+
}
443445
}
446+
} else {
447+
decompose(property, object, _valuesStart, _valuesEnd)
448+
}
449+
if (typeof start === 'number' && typeof end === 'string' && end[1] === '=') {
450+
continue
444451
}
445-
} else {
446-
decompose(property, object, _valuesStart, _valuesEnd)
447-
}
448-
if (typeof start === 'number' && typeof end === 'string' && end[1] === '=') {
449-
continue
450452
}
453+
_valuesStart.processed = true
451454
}
452455

453456
if (Tween.Renderer && this.node && Tween.Renderer.init) {

0 commit comments

Comments
 (0)