Skip to content

Callback: how to use? #119

@lordthistle

Description

@lordthistle

I am not able to have callback working. Unfortunately, I am not able to create a jsFiddle with a working textillate example, however I created this minimal code for reproducing the issue

In a HTML page I have these two spans:

<span class='tlt' style='visibility:hidden'>123456</span>
<span class='tlt' style = 'visibility:hidden'>789</span>

At the end of the HTML text I have:

<script>
        $(document).ready(function() {  
            magic_init();
        });
</script>

The function magic_init() is:

function magic_init() {
    elems = $('.tlt')
    n = $(elems).length
    
    console.log(n + ' to be animated')
    _textillate(elems, 0, n)
} // magic_init

function _textillate(elems, idx, maxIdx) {
    e = $(elems)[idx];
    if (idx < maxIdx-1) {
        console.log('Animating #' + idx + "/" + maxIdx)
        $(e).textillate({ in: { effect: 'rollIn',  callback: function() {console.log('callback'); }} });
    } else {
        $(e).textillate({ in: { effect: 'rollIn', } });
    }
}

With this I am able to animate only the first element, the console log contains only:

2 to be animated
Animating #0/2

Neither the second span is animated nor the callback message is logged

Is there anyone who can help me?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions