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

Choosing where to stop animation #3

Closed
borisdamevin opened this issue Sep 30, 2014 · 2 comments
Closed

Choosing where to stop animation #3

borisdamevin opened this issue Sep 30, 2014 · 2 comments

Comments

@borisdamevin
Copy link

Stop the animation okay, but you can choose which word stoper?
For example if I want the animation will stop on the last word, how do I do?

@MrSaints
Copy link
Owner

I'll add an option for an event callback (e.g. on animation complete) to be fired. You can then handle the logic there. Thanks for bringing this up. It only makes sense to have something like this to compliment the start() and stop(). Let me know if you have any suggestions on this.

@MrSaints
Copy link
Owner

Hey @borisdamevin,

This is just a quick update to your issue. I have added an option for an event callback (as mentioned in my previous comment) and it is named complete -- see 087facc. complete will be fired after every new phrase is introduced. The this context of complete will be that of the plugin's instance and hence, you may access its settings and methods using this.

With your scenario in mind, here are a few examples of how you may stop the animation at a certain phrase or index:

$("#js-rotating").Morphext({
    complete: function () {
        // 1. Stop if phrase index is 3
        if (this.index === 3) {
            this.stop();
        }

        // 2. Stop if phrase is "Stop here" by retrieving the current phrase through its index
        if (this.phrases[this.index] === "Stop here") {
            this.stop();
        }

        // 3. Stop at the last phrase
        if (this.index === this.phrases.length - 1) {
            this.stop();
        }
    }
});

I hope it helps!

Let me know if you have any other questions or problems.
I'll try my best to help you get it working.

Thanks!

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

No branches or pull requests

2 participants