Comments (7)
I'll see what I can come up with.
from jquery-minicolors.
Hi,
I faced the same issue and did a quick fix:
in updateFormControl() function, in Handle Color parts, I changed:
input.val( convertCase(hex, settings.letterCase) );
by
var rgb = hex2rgb(hex),
opacity = input.attr('data-opacity');
if(opacity && input.minicolors('rgbObject').a < 1 && rgb)
input.val('rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + parseFloat(opacity) + ')');
else{
input.val( convertCase(hex, settings.letterCase) );
}
Basically, if Opacity value = 1, then the input value will be in HEX format. But if Opacity value < 1, then the input value will be in RGBA format
Also i noticed the input value is updated if color is changed (with mousemouse), but not if Opacity is changed. Thus I also changed the selector:
if( target.is('.minicolors-grid, .minicolors-slider,') ) {
by
if( target.is('.minicolors-grid, .minicolors-slider, .minicolors-opacity-slider') ) {
from jquery-minicolors.
I don't believe that's what the original poster was asking about. It sounds like he wants to accept an RGB(A) value in the value
method. It looks like you're trying to show the RGB(A) value in the input element.
from jquery-minicolors.
I will probably say both of this cases are very useful. Currently I will like to be able to input and RGBA color on the field and also have the value
attribute be change to that. I there any way I can do that?
Thanks... Great plugin.
from jquery-minicolors.
RGB(A) isn't as user-friendly as hex colors, but for those who need it, feel free to submit a pull request. It will have to be thorough, since the plugin was only built to parse/output hex color strings.
For those who just need to get the RGB(A) value, the rgbObject
method will be useful:
$('input').minicolors('rgbObject') ---> Object {r: 255, g: 97, b: 97, a: .5}
I also thought of a simple algorithm for parsing RGB(A) strings in case it helps:
- Start with an RGB(A) string:
rgba(10, 20, 30, .5)
- Remove everything that's not a number, period, or comma:
10,20,30,.5
- Split at the comma:
[10, 20, 30, .5]
- Check each element for validity (e.g. 0-255 for colors, 0-1 for opacity)
from jquery-minicolors.
Hi all!
I have created a PR to allow rgba values input (and additionally, i have added the possibility to activate css color keywords (transparent, inherit, initial).
#170
Testing and feedback welcome!
Cyril
from jquery-minicolors.
See #170 for further discussion.
from jquery-minicolors.
Related Issues (20)
- Position failed HOT 1
- The position of the picker does not work correctly when the scale value of the body tag is changed. HOT 1
- Request: beforeShow event
- How to import minicolors with webpack? HOT 3
- Performance bugs HOT 3
- displaying HEX code in the color picker panel itself HOT 2
- getting a checked image when selecting a preset swatch HOT 4
- Problem with opacity + wheel HOT 1
- Option to show text input with `inline` option? HOT 1
- Scrolling on mobile HOT 5
- jQuery 4 deprecation warnings
- Any chance of updating this to HDR colours? HOT 1
- Updating settings with shorter array of swatches causes exception
- Initial selection is black HOT 1
- Update github website URL HOT 1
- Use 'Transparent' on swatches HOT 3
- Worst documentation I've even seen ! HOT 1
- bootstrap 5 theme & input-group
- Dynamically add mincolors to a field HOT 1
- Duplicated values in the swatch result in multiple same colors in the swatch HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-minicolors.