Skip to content

Commit

Permalink
Ensure starting from any transparent value uses the endpoint as its c…
Browse files Browse the repository at this point in the history
…olor the whole way through - Fixes #32
  • Loading branch information
gnarf committed Jul 4, 2012
1 parent 931f4f2 commit 92025e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion jquery.color.js
Expand Up @@ -315,7 +315,8 @@ color.fn = jQuery.extend( color.prototype, {
var end = color( other ),
spaceName = end._space(),
space = spaces[ spaceName ],
start = this[ space.cache ] || space.to( this._rgba ),
startColor = this.alpha() === 0 ? color( "transparent" ) : this,
start = startColor[ space.cache ] || space.to( startColor._rgba ),
result = start.slice();

end = end[ space.cache ];
Expand Down
11 changes: 10 additions & 1 deletion test/unit/color.js
Expand Up @@ -267,7 +267,7 @@ test( ".transition() works with $.Colors", function() {
trans = jQuery.Color( "transparent" ),
fifty = black.transition( whiteAlpha, 0.5 );

expect( 12 );
expect( 16 );
testParts( fifty, {
prefix: "black -> whiteAlpha 0.5",
red: 127,
Expand All @@ -289,6 +289,15 @@ test( ".transition() works with $.Colors", function() {
blue: 255,
alpha: 0.25
});

// fixes issue #32
testParts( jQuery.Color( 255, 0, 0, 0 ).transition( black, 0.5 ), {
prefix: "transparent red -> black 0.5",
red: 0,
green: 0,
blue: 0,
alpha: 0.5
});
});

test( ".transtion() works with strings and objects", function() {
Expand Down

0 comments on commit 92025e2

Please sign in to comment.