Skip to content

Commit

Permalink
In duration situation the ticks data is decreased by 1 on every tick.
Browse files Browse the repository at this point in the history
  • Loading branch information
pisi committed Oct 12, 2012
1 parent 2b38be8 commit 5388ed9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
4 changes: 3 additions & 1 deletion jquery.reel.js
Expand Up @@ -1603,7 +1603,9 @@ jQuery.reel || (function($, window, document, undefined){
var
direction= get(_cwish_) * negative_when(1, get(_backwards_)),
step= (!get(_playing_) ? velocity : abs(get(_speed_)) + velocity) / leader(_tempo_),
fraction= set(_fraction_, get(_fraction_) - step * direction)
ticks= get(_ticks_),
fraction= set(_fraction_, get(_fraction_) - step * direction),
ticks= opt.duration && ticks > 0 && set(_ticks_, ticks - 1)
},

// This handler performs the opening animation duty when during it the normal animation
Expand Down
29 changes: 29 additions & 0 deletions test/unit/animation.js
Expand Up @@ -239,4 +239,33 @@

});

asyncTest( 'Duration: Ticks count down to zero', function()
{
var
ticks_start,
expected,
samples= 5,
$reel= $('#image').reel({
speed: 1,
duration: 2
})

expect(samples);

$(document).bind('tick.reel.test', function(){
var
ticks= $reel.reel('ticks')

if (ticks != -1){
if (!ticks_start){
ticks_start= expected= ticks;
}else{
equal( ticks, --expected, ticks);
if (ticks <= ticks_start - samples) start();
}
}
})

});

})(jQuery);

0 comments on commit 5388ed9

Please sign in to comment.