Skip to content

Commit 64174eb

Browse files
committed
* code(core): removed circular prev and next access on Tween
* code(Tween): added missed relative code * and some fixes
1 parent 43c7f71 commit 64174eb

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,4 @@ Project maintainers who do not follow or enforce the Code of Conduct in good fai
4343
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
4444

4545
[homepage]: http://contributor-covenant.org
46-
<<<<<<< HEAD
47-
[version]: http://contributor-covenant.org/version/1/4/
48-
=======
49-
[version]: http://contributor-covenant.org/version/1/4/
50-
>>>>>>> c51a062... * docs(CODE_OF_CONDUCT): added
46+
[version]: http://contributor-covenant.org/version/1/4/

test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ test('Value Interpolation', t => {
5454
})
5555

5656
let tween = new Tween(obj)
57-
.to({ a: 1, b: 'B value 2', c: { x: 3 }, d: [4], _e: 5, g: '+1' }, 100)
57+
.to({ a: 1, b: 'B value 2', c: { x: 3 }, d: [4], _e: 5, g: '+=1' }, 100)
5858
.start(0)
5959

6060
update(0)
@@ -114,7 +114,7 @@ test('Value Array-based Interpolation', t => {
114114

115115
t.log('Start-value interpolation was done')
116116

117-
tween.update(100)
117+
update(100)
118118

119119
})
120120

ts/Tween.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,9 @@ class Tween {
498498
}
499499
}
500500
_valuesStart[property] = start;
501+
if (typeof start === 'number' && typeof end === 'string' && end[1] === '=') {
502+
continue
503+
}
501504
decompose(property, object, _valuesStart, _valuesEnd);
502505
}
503506

@@ -805,7 +808,9 @@ class Tween {
805808
end.update(value);
806809
} else if (typeof end === 'function') {
807810
object[property] = end(value);
808-
} else {
811+
} else if (typeof end === 'string' && typeof start === 'number') {
812+
object[property] = start + parseFloat(end[0] + end.substr(2)) * value
813+
} else {
809814
recompose(property, object, _valuesStart, _valuesEnd, value, elapsed);
810815
}
811816
if (Plugins[property] && Plugins[property].update) {
@@ -832,15 +837,22 @@ class Tween {
832837

833838
this.emit(EVENT_UPDATE, object, elapsed, time);
834839

835-
if (elapsed === 1 || (_reversed && !elapsed)) {
840+
if (elapsed === 1 || (_reversed && elapsed === 0)) {
836841
if (_repeat > 0 && _duration > 0) {
837842
if (_isFinite) {
838843
this._repeat--;
839844
}
840845

841846
if (_yoyo) {
842847
this._reversed = !_reversed;
843-
}
848+
} else {
849+
for (property in _valuesEnd) {
850+
let end = _valuesEnd[property]
851+
if (typeof end === 'string' && typeof _valuesStart[property] === 'number') {
852+
_valuesStart[property] += parseFloat(end[0] + end.substr(2))
853+
}
854+
}
855+
}
844856

845857
this.emit(_yoyo && !_reversed ? EVENT_REVERSE : EVENT_REPEAT, object);
846858

ts/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const hex2rgb = (all, hex) => {
6161
};
6262

6363
export function decomposeString(fromValue: string): any[] {
64-
return fromValue.replace(hexColor, hex2rgb).match(NUM_REGEX).map(v => (isNaNForST(v) ? v : +v));
64+
return typeof fromValue !== 'string' ? fromValue : fromValue.replace(hexColor, hex2rgb).match(NUM_REGEX).map(v => (isNaNForST(v) ? v : +v));
6565
}
6666

6767
// Decompose value, now for only `string` that required
@@ -83,7 +83,7 @@ export function decompose(prop, obj, from, to, stringBuffer?) {
8383
}
8484
}
8585

86-
if (fromValue1[0] !== STRING_PROP) {
86+
if (fromValue1[0] !== STRING_PROP && Array.isArray(fromValue1)) {
8787
fromValue1.unshift(STRING_PROP);
8888
}
8989
if (toValue1[0] !== STRING_PROP) {

ts/core.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ const add = (tween: any): void => {
7474
_tweens.splice(i, 1);
7575
}
7676

77-
if (_tweens.length > 0) {
78-
i = _tweens.length - 1;
79-
let tweenPrev = _tweens[i];
80-
tween.prev = tweenPrev;
81-
tweenPrev.next = tween;
82-
}
83-
8477
_tweens.push(tween);
8578

8679
emptyFrame = 0;

0 commit comments

Comments
 (0)