mirror of https://github.com/luileito/jsketch.git
Deep cloning default options
This commit is contained in:
parent
3b5cf577e0
commit
00948a5b21
|
|
@ -36,16 +36,12 @@
|
||||||
*/
|
*/
|
||||||
init: function(opts) {
|
init: function(opts) {
|
||||||
// Options will be available for all plugin methods.
|
// Options will be available for all plugin methods.
|
||||||
var options = $.extend({}, $.fn.sketchable.defaults, opts || {});
|
var options = $.extend(true, {}, $.fn.sketchable.defaults, opts || {});
|
||||||
return this.each(function() {
|
return this.each(function() {
|
||||||
var elem = $(this), data = elem.data(_ns);
|
var elem = $(this), data = elem.data(_ns);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
// TODO: Add more drawing properties (and set them configurable).
|
// TODO: Add more drawing properties (and set them configurable).
|
||||||
var sketch = new jSketch(this, {
|
var sketch = new jSketch(this, options.graphics);
|
||||||
fillStyle: options.graphics.fillStyle,
|
|
||||||
strokeStyle: options.graphics.strokeStyle,
|
|
||||||
lineWidth: options.graphics.lineWidth,
|
|
||||||
});
|
|
||||||
// Flag drawing state on a per-canvas basis.
|
// Flag drawing state on a per-canvas basis.
|
||||||
sketch.isDrawing = false;
|
sketch.isDrawing = false;
|
||||||
elem.data(_ns, {
|
elem.data(_ns, {
|
||||||
|
|
@ -251,7 +247,7 @@
|
||||||
},
|
},
|
||||||
// TODO: add more jSketch config options
|
// TODO: add more jSketch config options
|
||||||
graphics: {
|
graphics: {
|
||||||
firstPointSize: 0,
|
firstPointSize: 3,
|
||||||
lineWidth: 3,
|
lineWidth: 3,
|
||||||
strokeStyle: '#F0F',
|
strokeStyle: '#F0F',
|
||||||
fillStyle: '#F0F'
|
fillStyle: '#F0F'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue