flux icon indicating copy to clipboard operation
flux copied to clipboard

Modified oncomplete so it returns the object it was tweening

Open Edrem opened this issue 9 years ago • 1 comments
trafficstars

EDIT: My initial pull request was broken, fixed a small error when using :after and :oncomplete

This small change makes it very easy to chain together tweens and create repeats. For example.

local function tweenRepeat(obj) Flux.to(obj, 4, {x = 10}):after(4, {x = 0}):oncomplete(tweenRepeat) end

tweenRepeat(FanceObject:new())

Edrem avatar Mar 27 '16 03:03 Edrem

Thanks! This tiny modification makes it 10x more convenient to use. You don't need to create anonymous functions in your tween calls everywhere.

One small tweak still needs to be made to line 62 though, so it works if you stack multiple oncomplete functions (though I'm not sure when you would need that).

-- Your version: The second oncomplete function call: x() doesn't get the object.
self[field] = old and function() old(self.obj) x() end or x

I just did this:

self[field] = old and function(...) old(...) x(...) end or x

In case I ever want to edit things again to send more arguments to any of the callbacks, it should always work.

rgrams avatar Oct 01 '19 21:10 rgrams