Skip to content

Commit ad7b518

Browse files
committed
Transition 2.0: Fixing a condition causing issues on calling resume / pause on the same frame. Casenum #45908, #46052.
1 parent 423becb commit ad7b518

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

transition.lua

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -324,17 +324,21 @@ lib.pause = function( whatToPause )
324324
if targetType and not tween._generatedByComposer then
325325
if targetType == "all" then
326326
tween._paused = true
327+
tween._resume = false
327328
elseif targetType == "tag" then
328329
if tween.tag == iterationTarget then
329330
tween._paused = true
331+
tween._resume = false
330332
end
331333
elseif targetType == "displayobject" then
332334
if tween._target == iterationTarget then
333335
tween._paused = true
336+
tween._resume = false
334337
end
335338
elseif targetType == "transition" then
336339
if tween == iterationTarget then
337340
tween._paused = true
341+
tween._resume = false
338342
end
339343
end
340344
end
@@ -374,29 +378,33 @@ lib.resume = function( whatToResume )
374378
-- iterate the table
375379

376380
local transitionTable = lib._transitionTable
381+
377382
-- if enterframe was run already, if we have any running tweens they won't be in the lib._transitionTable variable, but in lib._enterFrameTweens
378383
if #transitionTable == 0 then
379384
transitionTable = lib._enterFrameTweens
380385
end
381386

382387
for i,tween in ipairs( transitionTable ) do
383-
-- check for any cancel lib variables
384-
-- only cancel if the tween was not generated by the composer library
385-
local shouldResumeTween = false
388+
-- check for any resume lib variables
389+
-- only resume if the tween was not generated by the composer library
386390
if targetType and not tween._generatedByComposer then
387391
if targetType == "all" then
388392
tween._resume = true
393+
tween._paused = false
389394
elseif targetType == "tag" then
390395
if tween.tag == iterationTarget then
391396
tween._resume = true
397+
tween._paused = false
392398
end
393399
elseif targetType == "displayobject" then
394400
if tween._target == iterationTarget then
395401
tween._resume = true
402+
tween._paused = false
396403
end
397404
elseif targetType == "transition" then
398405
if tween == whatToResume then
399406
tween._resume = true
407+
tween._paused = false
400408
end
401409
end
402410
end
@@ -471,7 +479,7 @@ function lib:enterFrame ( event )
471479
-- create a local copy of the transition table, to avoid a race condition
472480
local currentActiveTweens = lib._transitionTable
473481
lib._enterFrameTweens = lib._transitionTable
474-
482+
475483
lib._transitionTable = {}
476484

477485
-- get the current event time
@@ -482,7 +490,6 @@ function lib:enterFrame ( event )
482490

483491
-- iterate the transition table
484492
for i,tween in ipairs( currentActiveTweens ) do
485-
486493
-- if the transition object is paused
487494
if tween._paused then
488495
-- handle tweens marked as paused
@@ -511,7 +518,7 @@ function lib:enterFrame ( event )
511518

512519
-- nil out the lastPausedTime variable of the transition object
513520
tween._lastPausedTime = nil
514-
tween._paused = false
521+
tween._paused = nil
515522

516523
-- dispatch the onResume method on the object
517524
local listener = tween._onResume

0 commit comments

Comments
 (0)