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

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Edrem
Copy link

@Edrem Edrem commented Mar 27, 2016

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
Copy link

rgrams commented Oct 1, 2019

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