3

I want to animate text using jQuery and Textillate.js but it only works once using .click(); it needs to refresh the browser to animate the text when click. I hope someone can help.

My HTML:

<h1 class="test">Im so handome!</h1>

And this is the JavaScript

var asdf = $('.test');
asdf.click(function() {
    asdf.textillate({
        in: {
            effect: 'bounceIn'
        }
    });
});
4
  • 1
    From what I can see, there's just an animation for in, and that will probably not work on clicks after it's done. Aug 7, 2013 at 8:26
  • Have you tried defining a out animation? Aug 7, 2013 at 8:27
  • Do you want continuously bouncing In? Aug 7, 2013 at 8:28
  • i just tried the out animation but still nothing change. i only want to re animate again when i click the text
    – KevDev
    Aug 7, 2013 at 8:33

2 Answers 2

3

You should init the textillate plugin outside of click function, and then trigger the api within the click function.

This should work:

var asdf = $('.test');
asdf.textillate({
    autoStart: false,
    in: {
        effect: 'bounceIn'
    }
  });
var api = asdf.data('textillate');

asdf.click(function() {
  api.start();
});
1
  • 2
    Alternatively, you can call asdf.textillate('start') without needing to save off the data object.
    – jschr
    Aug 7, 2013 at 14:39
0

try this

var asdf = $('.test');
asdf.click(function() {
   setInterval(function(){
   asdf.textillate({
    in: {
        effect: 'bounceIn'
    }}, 200); 
  });
});

200 is to animate after each 200 milisec.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.