jdan / dynamo.js

Cycles through bits of text in place
http://jdan.github.io/dynamo.js/
MIT License
626 stars 65 forks source link

Run just one cycle #20

Closed christophbach closed 10 years ago

christophbach commented 10 years ago

Is there any way to stop a dynamo after only 1 cycle?

Setting a callback like this didn't work for me:

$('#dynamo-slogan').dynamo({
    ...
    callback: function() {
        $('#dynamo-slogan').dynamo({
            pause: true
        });
    }
});
jdan commented 10 years ago

You can do this by setting pause: true right off the bat, then calling

$('#dynamo-slogan').dynamo_trigger()

as many times as you need. You'll need to create your own timer in order to get the interval right.

Seems like a popular use-case though, so I'll probably work on a "once" option in the near future.

christophbach commented 10 years ago

Alright, that did it. Feels a bit ugly, but, yeah, it works.

A "once" option would be cool, maybe a cycle count or something like that.

My delay is 1300, so I did this:

setTimeout(function() {
    dynamoSlogan.dynamo_trigger();
}, 1300);

setTimeout(function() {
    dynamoSlogan.dynamo_trigger();
}, 2600);

setTimeout(function() {
    dynamoSlogan.dynamo_trigger();
}, 3900);
jdan commented 10 years ago

Yeah unfortunately it's a use-case we don't serve, and the code is structured in such a way that it's not trivial to implement.

I'm looking to rewrite most of the code such that you'll be able to access all of the dynamo object's properties, so that you could call something like .pause().

Glad to hear you found a temporary solution, though. Thanks for reporting :)