mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-19 05:31:07 +00:00
Clip path from json (#5279)
* better-than-nothing * check that the active object exist * test * added a test * added the code * added a test for this case
This commit is contained in:
parent
fdd2d94e77
commit
dd76fa2b6f
2 changed files with 19 additions and 2 deletions
|
|
@ -662,8 +662,11 @@
|
|||
object.filters = filters || [];
|
||||
fabric.Image.prototype._initFilters.call(object, [object.resizeFilter], function(resizeFilters) {
|
||||
object.resizeFilter = resizeFilters[0];
|
||||
var image = new fabric.Image(img, object);
|
||||
callback(image);
|
||||
fabric.util.enlivenObjects([object.clipPath], function(enlivedProps) {
|
||||
object.clipPath = enlivedProps[0];
|
||||
var image = new fabric.Image(img, object);
|
||||
callback(image);
|
||||
});
|
||||
});
|
||||
});
|
||||
}, null, object.crossOrigin);
|
||||
|
|
|
|||
|
|
@ -382,6 +382,20 @@
|
|||
});
|
||||
});
|
||||
|
||||
QUnit.test('fromObject with clipPath', function(assert) {
|
||||
var done = assert.async();
|
||||
// should not throw error when no callback is given
|
||||
var obj = fabric.util.object.extend(fabric.util.object.clone(REFERENCE_IMG_OBJECT), {
|
||||
src: IMG_SRC,
|
||||
clipPath: (new fabric.Rect({ width: 100, height: 100 })).toObject(),
|
||||
});
|
||||
fabric.Image.fromObject(obj, function(instance){
|
||||
assert.ok(instance instanceof fabric.Image);
|
||||
assert.ok(instance.clipPath instanceof fabric.Rect);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('fromObject does not mutate data', function(assert) {
|
||||
var done = assert.async();
|
||||
assert.ok(typeof fabric.Image.fromObject === 'function');
|
||||
|
|
|
|||
Loading…
Reference in a new issue