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

Repeat #9

Open
gustavostuff opened this issue May 14, 2020 · 5 comments
Open

Repeat #9

gustavostuff opened this issue May 14, 2020 · 5 comments

Comments

@gustavostuff
Copy link

It would be nice to have a repeat functionality. Something to repeat the whole transformation with options to reverse it "in time" as well.

@rxi
Copy link
Owner

rxi commented May 14, 2020

Have you tried the macro:toggle-record and macro:play commands (ctrl+shift+; and ctrl+;)?

@gustavostuff
Copy link
Author

OK so... I'm not sure if that was a joke and I didn't get it but I created a pull request.

@rxi
Copy link
Owner

rxi commented May 15, 2020

Sorry about that! The question made some sense in the context of another one of my projects, it's surprisingly easy to miss the repository title if you aren't looking for it.

Repeating a tween in flux is typically done by creating a local function that starts a tween (or sequence of tweens) and passing it as the oncomplete callback to the last tween in the chain if we want to loop it

@gustavostuff
Copy link
Author

and passing it as the oncomplete callback to the last tween in the chain if we want to loop it

that actually makes sense, I don't know why but I thought this was going to create a stack overflow error, but now that I think about it a little more, that's not the case, I was just confused.

I guess we can close this MR since it's not really that necessary, as you pointed.

@idbrii
Copy link

idbrii commented Jul 20, 2020

And it looks like you can do a delay before your repeat with an empty tween:

S.tween = flux.group()

-- Declare variable before assigning so function can capture this local reference.
-- Alternative is to make the function global.
-- Prevents "expected function or callable")
local loop_heartbeat

loop_heartbeat = function()
    local time = 0.5
    S.tween:to(S.heart, 0.5, { scale = 1.2, })
        :ease("backout")
        :after(time, { scale = 1.0, })
        :ease("backin")
        :oncomplete(loop_heartbeat)
end

S.tween:to(S.heart, 2, {
        scale = 1,
    })
    :delay(2)
    :ease("elasticout")
    :after(5, {}) -- delay before loop
    :oncomplete(loop_heartbeat)

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

No branches or pull requests

3 participants