I am using fabric js library for custom text. Color picker is working fine in all browser but it is not working in safari.
var canvas = new fabric.Canvas('canvas');
$('#fill').change(function(){
var obj = canvas.getActiveObject();
if(obj){
obj.setFill($(this).val());
}
canvas.renderAll();
});
$('#font').change(function(){
var obj = canvas.getActiveObject();
if(obj){
obj.setFontFamily($(this).val());
}
canvas.renderAll();
});
function addText() {
var oText = new fabric.IText('Tap and Type', {
left: 100,
top: 100 ,
});
canvas.add(oText);
canvas.setActiveObject(oText);
$('#fill, #font').trigger('change');
oText.bringToFront();
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://rawgit.com/kangax/fabric.js/master/dist/fabric.min.js"></script>
<input type="color" value="blue" id="fill" />
<select id="font">
<option>arial</option>
<option>tahoma</option>
<option>times new roman</option>
</select>
<button onclick="addText()">Add Custom Text</button>
<br />
<canvas id="canvas" width="750" height="550" style="border:1px solid #444"></canvas>
But this color picker is not working in mac (Safari browser). I don't know what is issue. I want to implement color picker to safari broswer.
The keyboard combination shortcut of Win+Shift+C will activate Color Picker regardless of what other application(s) are running.
To add a color picker in an HTML page, use an <input> tag with type = 'color' . The initial value can be set using the value property. This value needs to be set in hexadecimal because colors are represented as six-digit hexadecimal values following a hashtag ( # ).
Nowadays, the color pickers in most image and video editing software include a feature that will identify a color in an image based on its RGB or hexadecimal (HEX) values. When you are using a color picker, you can click a space that contains a color in question and the color picker will display it.
To achieve disabled state in ColorPicker, set the disabled property to true . The ColorPicker pop-up cannot be accessed in disabled state.
as reported here:
http://caniuse.com/#feat=input-color
The input type color is not supported on safari 9.1 There are nice libraries in js that allow you to have quickly and easy a nice input color widget.
One of those is: http://jscolor.com/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With