mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-22 06:54:42 +00:00
fabric.Object#set can now be passed an object of property/value pairs rather than just property and value. E.g.: rect.set({ width: 100, height: 50, fill: 'red' }).
This commit is contained in:
parent
b15b319ed5
commit
d7fd8f0af3
4 changed files with 41 additions and 13 deletions
|
|
@ -57,7 +57,8 @@ Fabric.js started as a foundation for design editor on [printio.ru](http://print
|
|||
|
||||
### Demos
|
||||
|
||||
- [Main demo](http://kangax.github.com/fabric.js/test/demo/)
|
||||
- [Kitchen-sink (Main demo)](http://kangax.github.com/fabric.js/test/demo/)
|
||||
- [Miscellaneous demos](http://kangax.github.com/fabric.js/demos/)
|
||||
- [Benchmark (quantity)](http://kangax.github.com/fabric.js/test/benchmarks/quantity.html)
|
||||
- [Benchmark (animation)](http://kangax.github.com/fabric.js/test/benchmarks/animation.html)
|
||||
- [Benchmark (Raphael vs. Fabric; simple shapes)](http://kangax.github.com/fabric.js/test/raphael_vs_fabric/simple_shapes.html)
|
||||
|
|
|
|||
22
dist/all.js
vendored
22
dist/all.js
vendored
|
|
@ -1,6 +1,6 @@
|
|||
/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
|
||||
|
||||
var fabric = fabric || { version: "0.2.5" };
|
||||
var fabric = fabric || { version: "0.2.7" };
|
||||
|
||||
/**
|
||||
* Wrapper around `console.log` (when available)
|
||||
|
|
@ -6012,7 +6012,7 @@ fabric.util.animate = animate;
|
|||
|
||||
var clone = this.__clone || (this.__clone = new fabric.Element(el));
|
||||
clone.clipTo = this.clipTo;
|
||||
|
||||
|
||||
return clone.loadFromJSON(JSON.stringify(this.toJSON()), function () {
|
||||
if (callback) {
|
||||
callback(clone);
|
||||
|
|
@ -6219,13 +6219,13 @@ fabric.util.animate = animate;
|
|||
* @property
|
||||
* @type String
|
||||
*/
|
||||
type: 'object',
|
||||
type: 'object',
|
||||
|
||||
/**
|
||||
* @property
|
||||
* @type Boolean
|
||||
*/
|
||||
includeDefaultValues: true,
|
||||
includeDefaultValues: true,
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
|
@ -6439,12 +6439,20 @@ fabric.util.animate = animate;
|
|||
if (shouldConstrainValue) {
|
||||
value = this.MIN_SCALE_LIMIT;
|
||||
}
|
||||
if (property === 'angle') {
|
||||
this.setAngle(value);
|
||||
if (typeof property == 'object') {
|
||||
for (var prop in property) {
|
||||
this.set(prop, property[prop]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this[property] = value;
|
||||
if (property === 'angle') {
|
||||
this.setAngle(value);
|
||||
}
|
||||
else {
|
||||
this[property] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@
|
|||
* @property
|
||||
* @type String
|
||||
*/
|
||||
type: 'object',
|
||||
type: 'object',
|
||||
|
||||
/**
|
||||
* @property
|
||||
* @type Boolean
|
||||
*/
|
||||
includeDefaultValues: true,
|
||||
includeDefaultValues: true,
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
|
@ -246,12 +246,20 @@
|
|||
if (shouldConstrainValue) {
|
||||
value = this.MIN_SCALE_LIMIT;
|
||||
}
|
||||
if (property === 'angle') {
|
||||
this.setAngle(value);
|
||||
if (typeof property == 'object') {
|
||||
for (var prop in property) {
|
||||
this.set(prop, property[prop]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this[property] = value;
|
||||
if (property === 'angle') {
|
||||
this.setAngle(value);
|
||||
}
|
||||
else {
|
||||
this[property] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -56,9 +56,20 @@
|
|||
equals(cObj.get('width'), 51);
|
||||
equals(cObj.get('height'), 61);
|
||||
equals(cObj.get('opacity'), 0.5);
|
||||
|
||||
equals(cObj.set('opacity', 0.5), cObj, 'chainable');
|
||||
});
|
||||
|
||||
test('set with object of prop/values', function() {
|
||||
var cObj = new fabric.Object({ });
|
||||
|
||||
equals(cObj, cObj.set({ width: 99, height: 88, fill: 'red' }), 'chainable');
|
||||
|
||||
equals('red', cObj.get('fill'));
|
||||
equals(99, cObj.get('width'));
|
||||
equals(88, cObj.get('height'));
|
||||
});
|
||||
|
||||
test('setSourcePath', function() {
|
||||
var cObj = new fabric.Object();
|
||||
var SRC_PATH = 'http://example.com/';
|
||||
|
|
|
|||
Loading…
Reference in a new issue