Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Color picker is not working in safari browser

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.

like image 387
Varun Sharma Avatar asked May 20 '16 05:05

Varun Sharma


People also ask

How do I turn on color picker?

The keyboard combination shortcut of Win+Shift+C will activate Color Picker regardless of what other application(s) are running.

How do I use color picker on my website?

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 ( # ).

How does a color picker work?

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.

How do I disable color picker?

To achieve disabled state in ColorPicker, set the disabled property to true . The ColorPicker pop-up cannot be accessed in disabled state.


1 Answers

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/

like image 115
AndreaBogazzi Avatar answered Sep 22 '22 12:09

AndreaBogazzi