Skip to content

Setting alpha via an object doesn't work #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
derekcicerone-zz opened this issue May 8, 2013 · 3 comments
Closed

Setting alpha via an object doesn't work #58

derekcicerone-zz opened this issue May 8, 2013 · 3 comments

Comments

@derekcicerone-zz
Copy link

$.Color({red: 10, green: 10, blue: 10, alpha: 0.5}) results in a color with alpha set to 1.

The bug appears to be at line 276 in this section:
// everything defined but alpha?
if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
// use the default of 1
inst[ cache ][ 3 ] = 1;
if ( space.from ) {
inst._rgba = space.from( inst[ cache ] );
}
}

It seems to just clear out the alpha every time.

@rvaidya
Copy link

rvaidya commented Apr 16, 2015

This still seems to be an issue, 2 years later.

The workaround is to do $.Color({red: 10, green: 10, blue: 10, alpha: 0.5}).alpha(0.5), but then what's the point of having it in the constructor in the first place?

Also affects HSLA.

mgol added a commit to mgol/jquery-color that referenced this issue Jan 24, 2018
Before this commit the following code:

    jQuery.Color( { red: 10, green: 20, blue: 30, alpha: 0.4 } )

was incorrectly creating a Color object with the alpha property set to 1.

Fixes jquery#58
@mgol mgol mentioned this issue Jan 31, 2018
@mgol mgol closed this as completed in 0fbc05e Jan 31, 2018
@mgol
Copy link
Member

mgol commented Jan 31, 2018

jQuery Color 3.0.0-alpha.1 has been published to npm under the tag beta. It's also on the CDN: https://code.jquery.com/color/3.0.0-alpha.1/jquery.color.js.

Please test and report any issues before we release the final!

@mgol
Copy link
Member

mgol commented May 11, 2020

Released in jQuery Color 2.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants