BKWLD / tram

Cross-browser CSS3 transitions in JavaScript.
186 stars 23 forks source link

Support chaining with wait() #16

Closed weotch closed 10 years ago

weotch commented 11 years ago

I'd like this to work:

    $(this).tram()
            .set({opacity:0, top:-3})
            .add('opacity 400ms')
            .add('top 400ms ease-out')
            .wait(i*80)
            .then(function() { this.start({opacity: 1, top: 0}); })
            .wait(500)
            .then(function() { this.start({opacity: 0}); })
        ;
    });

I tried putting the second wait() inside of a then() but that didn't work. What I'm seeing is the first then() running but not the second.

weotch commented 11 years ago

FWIW, this does work:

$(this).tram()
    .set({opacity:0, top:-5})
    .add('opacity 400ms')
    .add('top 400ms ease-out')
    .wait(i*80)
    .then(function() { 
        this.start({opacity: 1, top: 0})
            .wait(500)
            .then(function() { this.start({opacity: 0}); })
        ; 
    })
;

It's just a little gnarly

danro commented 10 years ago

Hey dude, sorry for the delayed response. Your first block can be rewritten as:

$(this).tram()
    .set({opacity:0, top:-3})
    .add('opacity 400ms')
    .add('top 400ms ease-out')
    .wait(i*80)
    .then({ opacity: 1, top: 0})
    .wait(500)
    .then({opacity: 0})
;
weotch commented 10 years ago

Well that's nice.

With recent commits, should my initial example work now as well? Or does using closures in then() break it?