Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: endless concat #621

Merged
merged 3 commits into from
Apr 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Tween.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ export class Tween<T extends UnknownProps> {
endValues = endValues.map(this._handleRelativeValue.bind(this, startValue as number))

// Create a local copy of the Array with the start value at the front
_valuesEnd[property] = [startValue].concat(endValues)
if (_valuesStart[property] === undefined) {
_valuesEnd[property] = [startValue].concat(endValues)
}
}

// handle the deepness of the values
Expand Down
14 changes: 14 additions & 0 deletions src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2146,6 +2146,20 @@ export const tests = {
test.done()
},

"Test TWEEN.to(ends) shouldn't grow endless on ends value"(test: Test): void {
const target = {y: 0}
const ends = {y: [100, 200]}
const tween = new TWEEN.Tween(target).to(ends, 1000)

tween.stop().start(0)
tween.stop().start(0)

TWEEN.update(250)
test.equal(target.y, 50)

test.done()
},

'Test TWEEN.Tween.update() with no arguments'(test: Test): void {
const clock = FakeTimers.install()
const targetNow = {x: 0.0}
Expand Down