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

Commit

Permalink
* code(core): removed circular prev and next access on Tween
Browse files Browse the repository at this point in the history
* code(Tween): added missed relative code
* and some fixes
  • Loading branch information
dalisoft committed Nov 24, 2017
1 parent 43c7f71 commit 64174eb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
6 changes: 1 addition & 5 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,4 @@ Project maintainers who do not follow or enforce the Code of Conduct in good fai
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
<<<<<<< HEAD
[version]: http://contributor-covenant.org/version/1/4/
=======
[version]: http://contributor-covenant.org/version/1/4/
>>>>>>> c51a062... * docs(CODE_OF_CONDUCT): added
[version]: http://contributor-covenant.org/version/1/4/
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test('Value Interpolation', t => {
})

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

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

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

tween.update(100)
update(100)

})

Expand Down
18 changes: 15 additions & 3 deletions ts/Tween.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,9 @@ class Tween {
}
}
_valuesStart[property] = start;
if (typeof start === 'number' && typeof end === 'string' && end[1] === '=') {
continue
}
decompose(property, object, _valuesStart, _valuesEnd);
}

Expand Down Expand Up @@ -805,7 +808,9 @@ class Tween {
end.update(value);
} else if (typeof end === 'function') {
object[property] = end(value);
} else {
} else if (typeof end === 'string' && typeof start === 'number') {
object[property] = start + parseFloat(end[0] + end.substr(2)) * value
} else {
recompose(property, object, _valuesStart, _valuesEnd, value, elapsed);
}
if (Plugins[property] && Plugins[property].update) {
Expand All @@ -832,15 +837,22 @@ class Tween {

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

if (elapsed === 1 || (_reversed && !elapsed)) {
if (elapsed === 1 || (_reversed && elapsed === 0)) {
if (_repeat > 0 && _duration > 0) {
if (_isFinite) {
this._repeat--;
}

if (_yoyo) {
this._reversed = !_reversed;
}
} else {
for (property in _valuesEnd) {
let end = _valuesEnd[property]
if (typeof end === 'string' && typeof _valuesStart[property] === 'number') {
_valuesStart[property] += parseFloat(end[0] + end.substr(2))
}
}
}

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

Expand Down
4 changes: 2 additions & 2 deletions ts/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const hex2rgb = (all, hex) => {
};

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

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

if (fromValue1[0] !== STRING_PROP) {
if (fromValue1[0] !== STRING_PROP && Array.isArray(fromValue1)) {
fromValue1.unshift(STRING_PROP);
}
if (toValue1[0] !== STRING_PROP) {
Expand Down
7 changes: 0 additions & 7 deletions ts/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ const add = (tween: any): void => {
_tweens.splice(i, 1);
}

if (_tweens.length > 0) {
i = _tweens.length - 1;
let tweenPrev = _tweens[i];
tween.prev = tweenPrev;
tweenPrev.next = tween;
}

_tweens.push(tween);

emptyFrame = 0;
Expand Down

0 comments on commit 64174eb

Please sign in to comment.