Skip to content
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

Change hex to rgba when alpha is changed #219

Open
anthonyryanrusso opened this issue Jun 10, 2020 · 2 comments
Open

Change hex to rgba when alpha is changed #219

anthonyryanrusso opened this issue Jun 10, 2020 · 2 comments
Labels
question Further information is requested

Comments

@anthonyryanrusso
Copy link

anthonyryanrusso commented Jun 10, 2020

Is it possible for a the picker to start with a hex value and then change to rgba when the alpha is changed?

E.g. the pickr starts off as #ffffff but the alpha is changed to .8 so now the pickr displays it as rgba(255, 255, 255, .8)

@anthonyryanrusso anthonyryanrusso added the question Further information is requested label Jun 10, 2020
@simonwep
Copy link
Owner

You could listen for the change event, check if the color has an alpha value and change the representation with setColorRepresentation to RGBA

@CodeExplore
Copy link

It means:

// pickr is your instance.
pickr.on('change', function( color ) {
   if ( color.a === 1 ) {
    pickr.setColorRepresentation('HEX');
  } else {
    pickr.setColorRepresentation('RGBA');
  }
});

@simonwep simonwep removed their assignment Jun 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants