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

Commit 01b165e

Browse files
committed
fix(core): recalling same tween doesn't happen
1 parent cf85c2d commit 01b165e

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/core.js

+2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ const autoPlay = (state) => {
137137
const removeAll = () => {
138138
_tweens.length = 0
139139
cancelAnimationFrame(_tick)
140+
isStarted = false
140141
}
141142

142143
/**
@@ -180,6 +181,7 @@ const remove = (tween) => {
180181
}
181182
if (_tweens.length === 0) {
182183
cancelAnimationFrame(_tick)
184+
isStarted = false
183185
}
184186
}
185187

test.js

+26
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,32 @@ test('Tween update should be run against all tween each time', t => {
202202
t.deepEqual(order, [0, 1, 2])
203203
})
204204

205+
test('Tween should work after recall when using power saving feature', t => {
206+
const init = (obj) =>
207+
new Tween(obj)
208+
.to({ z: 360 }, 1000)
209+
.on('complete', init)
210+
.start(0)
211+
212+
const obj1 = { z: 0 }
213+
init(obj1)
214+
215+
update(500)
216+
t.is(obj1.z, 180, 'Tweening update does not work as excepted')
217+
update(1000)
218+
t.is(obj1.z, 360, 'Tweening update does not work as excepted')
219+
220+
update(0)
221+
222+
const obj2 = { z: 0 }
223+
init(obj2)
224+
225+
update(500)
226+
t.is(obj2.z, 180, 'Tweening update does not work as excepted')
227+
update(1000)
228+
t.is(obj2.z, 360, 'Tweening update does not work as excepted')
229+
})
230+
205231
test('Headless tests', browserTestMiddleware, (t, page) => {
206232
return page.evaluate(() => {
207233
const deepArrayCopy = arr => arr.map(child => Array.isArray(child)

0 commit comments

Comments
 (0)