Skip to content

Tween has chance to be played 2 times rapidly in a timeline. #276

@seafloyd16

Description

@seafloyd16

mojs version 1.7.1 (CDN)

In the code below, create a new timeline and append 5 tweens to it.
And then play the timeline that repeats infinite times.
The tweens add 1 to 'counter' and set it to 0 at the end.
"counter" must be 0 or 1.
If counter reaches higher than 1, tween throws an error.

If the timeline is played properly, there should be no errors.
But it is there.

var counter = 0; // <-- This must be 0 or 1
var tm = new mojs.Timeline
(
    {
        repeat: 0,
        onComplete: function()
        {
            tm.reset();
            tm.play();
        }
    }
);

function newTween()
{
    const t = new mojs.Tween
    (
        {
            duration: 500,
            easing: 'linear.none',
            repeat: 0,
            onStart: function()
            {
                counter ++;
                console.log(counter);
                if(counter > 1)
                throw 'BAD!!'; // <-- This must not happen
            },
            onComplete: function()
            {
                counter = 0;
            }
        }
    );
    return t;
}

for(var i = 0; i < 5; i++)
{
    tm.append(newTween());
}

tm.play();

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionneeding further explanations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions