Skip to content

Modified oncomplete so it returns the object it was tweening#5

Open
Edrem wants to merge 2 commits into
rxi:masterfrom
Edrem:master
Open

Modified oncomplete so it returns the object it was tweening#5
Edrem wants to merge 2 commits into
rxi:masterfrom
Edrem:master

Conversation

@Edrem

@Edrem Edrem commented Mar 27, 2016

Copy link
Copy Markdown

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 added 2 commits March 26, 2016 21:15
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(obj)
@rgrams

rgrams commented Oct 1, 2019

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants