jschr / textillate

A jquery plugin for CSS3 text animations.
http://textillate.js.org
MIT License
3.66k stars 762 forks source link

Not working with JS array of strings #88

Closed Snazzyham closed 6 years ago

Snazzyham commented 8 years ago

So I'm trying to build a random quote generator and right now I've got an array;

var quotes = ["this is quote one", "quote two"]

and then I've got some code that calculates a random number and I end up with

quoteDiv.innerHTML = quotes[quotePosition];

and in my HTML I've got

<div id="quoteDiv"></div>

and everything works fine but no matter where I add the .tlt class to for textillate, I can't seem to get it to animate the text, it just shows the text without animating it.

My apologies for not being very clear with what I'm working with, but any help would be appreciated.

jschr commented 8 years ago

Hey @Snazzyham

Currently Textillate doesn't support rendering JS strings nicely. This is would a great enhancement for v2.

In the meantime, you need to manually construct the correct html structure before initializing the plugin:

<h1 class="tlt">
    <ul class="texts">
        <li data-out-effect="fadeOut" data-out-shuffle="true">Some Title</li>   
        <li data-in-effect="fadeIn">Another Title</li>
    </ul>
</h1>

Here is an example: http://jsfiddle.net/jschr/81xb9nyy/

Snazzyham commented 8 years ago

Hey Jordan, 

Thanks for your response. I appreciate it. 

Soham Adwani | Tech Enthusiast  @snazzyham

On 22 December 2015 at 10:41:06 PM, Jordan Schroter (notifications@github.com) wrote:

Hey @Snazzyham

Currently Textillate doesn't support rendering JS strings nicely. This is would a great enhancement for v2.

In the meantime, you need to manually construct the correct html structure before initializing the plugin:

  • Some Title
  • Another Title

Here is an example: http://jsfiddle.net/jschr/81xb9nyy/

— Reply to this email directly or view it on GitHub.

naivefun commented 8 years ago

Is it possible to dynamically insert li node to play dynamic events or notification?

jschr commented 8 years ago

@naivefun unfortunately textillate could handle dynamic text a lot better, definitely something I wanna do in future version. For right now I think you're stuck with removing and initializing a new textillate instance.