Comparing version 1.4.0 to 1.4.1
**Edge** | ||
- [BACK_INCOMPAT] `fabric.Collection#remove` doesn't return removed object -> returns `this` (chainable) | ||
- Add "mouse:over" and "mouse:out" canvas events (and corresponding "mouseover", "mouseout" object events) | ||
- Fix paths parsing when number has negative exponent | ||
- Fix background offset in iText | ||
- Fix style object deletion in iText | ||
- Fix typo in `_initCanvasHandlers` | ||
- Fix `transformMatrix` not affecting fabric.Text | ||
**Version 1.4.0** | ||
- [BACK_INCOMPAT] JSON and Cufon are no longer included in default build | ||
- [BACK_INCOMPAT] Change default objects' originX/originY to left/top | ||
@@ -4,0 +18,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"keywords": ["canvas", "graphic", "graphics", "SVG", "node-canvas", "parser", "HTML5", "object model"], | ||
@@ -12,4 +12,4 @@ "dependencies": {}, | ||
"scripts": [ | ||
"./dist/all.js" | ||
"./dist/fabric.js" | ||
] | ||
} |
@@ -37,3 +37,3 @@ # Contributing to Fabric | ||
- **Fabric.js version:** Make sure to specify which version of Fabric.js you are using. The version can be found in [all.js file](https://github.com/kangax/fabric.js/blob/master/dist/all.js#L5) or just by executing `fabric.version` in the browser console. | ||
- **Fabric.js version:** Make sure to specify which version of Fabric.js you are using. The version can be found in [fabric.js file](https://github.com/kangax/fabric.js/blob/master/dist/fabric.js#L5) or just by executing `fabric.version` in the browser console. | ||
@@ -40,0 +40,0 @@ ## Pull requests |
{ | ||
"name": "fabric", | ||
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"author": "Juriy Zaytsev <kangax@gmail.com>", | ||
@@ -18,3 +18,3 @@ "keywords": ["canvas", "graphic", "graphics", "SVG", "node-canvas", "parser", "HTML5", "object model"], | ||
"canvas": "1.0.x", | ||
"jsdom": "0.7.x", | ||
"jsdom": "0.8.x", | ||
"xmldom": "0.1.x" | ||
@@ -30,3 +30,3 @@ }, | ||
"engines": { "node": ">=0.4.0 && <1.0.0" }, | ||
"main": "./dist/all.js" | ||
"main": "./dist/fabric.js" | ||
} |
@@ -1,2 +0,2 @@ | ||
<a href="http://fabricjs.challengepost.com/?utm_source=partner&utm_medium=banner&utm_campaign=fabricjs" style="display: block"> | ||
<a href="http://fabricjs.challengepost.com/?utm_source=partner&utm_medium=banner&utm_campaign=fabricjs" style="display:block"> | ||
<img src="https://dl.dropboxusercontent.com/u/822184/fabric-js-promo-widget-github.gif" style="width: auto"> | ||
@@ -7,5 +7,4 @@ </a> | ||
[![Build Status](https://secure.travis-ci.org/kangax/fabric.js.png?branch=master)](http://travis-ci.org/#!/kangax/fabric.js) | ||
[![Code Climate](https://codeclimate.com/repos/526a0ed089af7e6cf2001389/badges/d1c922dd1511ffa8a72f/gpa.png)](https://codeclimate.com/repos/526a0ed089af7e6cf2001389/feed) | ||
[![Coverage Status](https://coveralls.io/repos/kangax/fabric.js/badge.png?branch=master)](https://coveralls.io/r/kangax/fabric.js?branch=master) | ||
<a href="https://npmjs.org/package/fabric"><img src="https://badge.fury.io/js/fabric.png"></a> | ||
@@ -109,3 +108,3 @@ | ||
//# sourceMappingURL=all.min.js.map | ||
//# sourceMappingURL=fabric.min.js.map | ||
@@ -143,7 +142,7 @@ ### Demos | ||
- **requirejs** — Makes fabric requirejs AMD-compatible in `dist/all.js`. *Note:* an unminified, requirejs-compatible version is always created in `dist/all.require.js` | ||
- **requirejs** — Makes fabric requirejs AMD-compatible in `dist/fabric.js`. *Note:* an unminified, requirejs-compatible version is always created in `dist/fabric.require.js` | ||
- **no-strict** — Strips "use strict" directives from source | ||
- **no-svg-export** — Removes svg exporting functionality | ||
- **no-es5-compat** - Removes ES5 compat methods (Array.prototype.*, String.prototype.*, Function.prototype.*) | ||
- **sourcemap** - Generates a sourceMap file and adds the `sourceMappingURL` (only if uglifyjs is used) to `dist/all.min.js` | ||
- **sourcemap** - Generates a sourceMap file and adds the `sourceMappingURL` (only if uglifyjs is used) to `dist/fabric.min.js` | ||
@@ -158,16 +157,33 @@ For example: | ||
<canvas id="canvas" width="300" height="300"></canvas> | ||
... | ||
var canvas = new fabric.Canvas('canvas'); | ||
```html | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
<canvas id="canvas" width="300" height="300"></canvas> | ||
var rect = new fabric.Rect({ | ||
top: 100, | ||
left: 100, | ||
width: 60, | ||
height: 70, | ||
fill: 'red' | ||
}); | ||
<script src="lib/fabric.js"></script> | ||
<script> | ||
var canvas = new fabric.Canvas('canvas'); | ||
canvas.add(rect); | ||
var rect = new fabric.Rect({ | ||
top : 100, | ||
left : 100, | ||
width : 60, | ||
height : 70, | ||
fill : 'red' | ||
}); | ||
canvas.add(rect); | ||
</script> | ||
</body> | ||
</html> | ||
``` | ||
### Helping Fabric | ||
- [Fabric on Bountysource](https://www.bountysource.com/trackers/23217-fabric-js) | ||
- [Fabric on CodeTriage](http://www.codetriage.com/kangax/fabric.js) | ||
### Staying in touch | ||
@@ -174,0 +190,0 @@ |
@@ -9,3 +9,3 @@ var testrunner = require('qunit'); | ||
deps: "./test/fixtures/test_script.js", | ||
code: "./dist/all.js", | ||
code: "./dist/fabric.js", | ||
tests: [ | ||
@@ -12,0 +12,0 @@ './test/unit/rect.js', |
@@ -193,14 +193,21 @@ (function() { | ||
ok(typeof canvas.calcOffset == 'function', 'should respond to `calcOffset`'); | ||
equal(canvas, canvas.calcOffset()); | ||
equal(canvas.calcOffset(), canvas, 'should be chainable'); | ||
}); | ||
test('add', function() { | ||
var rect = makeRect(); | ||
var rect1 = makeRect(), | ||
rect2 = makeRect(), | ||
rect3 = makeRect(), | ||
rect4 = makeRect(); | ||
ok(typeof canvas.add == 'function'); | ||
ok(canvas === canvas.add(rect), 'should be chainable'); | ||
equal(canvas.item(0), rect); | ||
equal(canvas.add(rect1), canvas, 'should be chainable'); | ||
strictEqual(canvas.item(0), rect1); | ||
canvas.add(makeRect(), makeRect(), makeRect()); | ||
canvas.add(rect2, rect3, rect4); | ||
equal(canvas.getObjects().length, 4, 'should support multiple arguments'); | ||
strictEqual(canvas.item(1), rect2); | ||
strictEqual(canvas.item(2), rect3); | ||
strictEqual(canvas.item(3), rect4); | ||
}); | ||
@@ -222,3 +229,3 @@ | ||
ok(canvas === canvas.add(rect), 'should be chainable'); | ||
equal(canvas.add(rect), canvas, 'should be chainable'); | ||
equal(renderAllCount, 0); | ||
@@ -239,2 +246,28 @@ | ||
test('object:added', function() { | ||
var objectsAdded = []; | ||
canvas.on('object:added', function(e) { | ||
objectsAdded.push(e.target); | ||
}); | ||
var rect = new fabric.Rect({ width: 10, height: 20 }); | ||
canvas.add(rect); | ||
deepEqual(objectsAdded[0], rect); | ||
var circle1 = new fabric.Circle(), | ||
circle2 = new fabric.Circle(); | ||
canvas.add(circle1, circle2); | ||
strictEqual(objectsAdded[1], circle1); | ||
strictEqual(objectsAdded[2], circle2); | ||
var circle3 = new fabric.Circle(); | ||
canvas.insertAt(circle3, 2); | ||
strictEqual(objectsAdded[3], circle3); | ||
}); | ||
test('insertAt', function() { | ||
@@ -250,6 +283,6 @@ var rect1 = makeRect(), | ||
canvas.insertAt(rect, 1); | ||
equal(canvas.item(1), rect); | ||
strictEqual(canvas.item(1), rect); | ||
canvas.insertAt(rect, 2); | ||
equal(canvas.item(2), rect); | ||
equal(canvas, canvas.insertAt(rect, 2), 'should be chainable'); | ||
strictEqual(canvas.item(2), rect); | ||
equal(canvas.insertAt(rect, 2), canvas, 'should be chainable'); | ||
}); | ||
@@ -280,3 +313,3 @@ | ||
equal(canvas.item(1), rect); | ||
strictEqual(canvas.item(1), rect); | ||
canvas.insertAt(rect, 2); | ||
@@ -292,5 +325,80 @@ equal(renderAllCount, 0); | ||
test('remove', function() { | ||
var rect1 = makeRect(), | ||
rect2 = makeRect(), | ||
rect3 = makeRect(), | ||
rect4 = makeRect(); | ||
canvas.add(rect1, rect2, rect3, rect4); | ||
ok(typeof canvas.remove == 'function'); | ||
equal(canvas.remove(rect1), canvas, 'should be chainable'); | ||
strictEqual(canvas.item(0), rect2, 'should be second object'); | ||
canvas.remove(rect2, rect3); | ||
strictEqual(canvas.item(0), rect4); | ||
canvas.remove(rect4); | ||
equal(canvas.isEmpty(), true, 'canvas should be empty'); | ||
}); | ||
test('remove renderOnAddRemove disabled', function() { | ||
var rect1 = makeRect(), | ||
rect2 = makeRect(), | ||
originalRenderOnAddition, | ||
renderAllCount = 0; | ||
function countRenderAll() { | ||
renderAllCount++; | ||
} | ||
originalRenderOnAddition = canvas.renderOnAddRemove; | ||
canvas.renderOnAddRemove = false; | ||
canvas.on('after:render', countRenderAll); | ||
canvas.add(rect1, rect2); | ||
equal(renderAllCount, 0); | ||
equal(canvas.remove(rect1), canvas, 'should be chainable'); | ||
equal(renderAllCount, 0); | ||
strictEqual(canvas.item(0), rect2, 'only second object should be left'); | ||
canvas.renderAll(); | ||
equal(renderAllCount, 1); | ||
canvas.off('after:render', countRenderAll); | ||
canvas.renderOnAddRemove = originalRenderOnAddition; | ||
}); | ||
test('object:removed', function() { | ||
var objectsRemoved = []; | ||
canvas.on('object:removed', function(e) { | ||
objectsRemoved.push(e.target); | ||
}); | ||
var rect = new fabric.Rect({ width: 10, height: 20 }), | ||
circle1 = new fabric.Circle(), | ||
circle2 = new fabric.Circle(); | ||
canvas.add(rect, circle1, circle2); | ||
strictEqual(canvas.item(0), rect); | ||
strictEqual(canvas.item(1), circle1); | ||
strictEqual(canvas.item(2), circle2); | ||
canvas.remove(rect); | ||
strictEqual(objectsRemoved[0], rect); | ||
canvas.remove(circle1, circle2); | ||
strictEqual(objectsRemoved[1], circle1); | ||
strictEqual(objectsRemoved[2], circle2); | ||
equal(canvas.isEmpty(), true, 'canvas should be empty'); | ||
}); | ||
test('clearContext', function() { | ||
ok(typeof canvas.clearContext == 'function'); | ||
equal(canvas, canvas.clearContext(canvas.contextContainer), 'chainable'); | ||
equal(canvas.clearContext(canvas.contextContainer), canvas, 'should be chainable'); | ||
}); | ||
@@ -301,3 +409,3 @@ | ||
equal(canvas, canvas.clear()); | ||
equal(canvas.clear(), canvas, 'should be chainable'); | ||
equal(canvas.getObjects().length, 0); | ||
@@ -675,40 +783,2 @@ }); | ||
test('remove', function() { | ||
ok(typeof canvas.remove == 'function'); | ||
var rect1 = makeRect(), | ||
rect2 = makeRect(); | ||
canvas.add(rect1, rect2); | ||
equal(canvas.remove(rect1), rect1, 'should return removed object'); | ||
equal(canvas.item(0), rect2, 'only second object should be left'); | ||
}); | ||
test('remove renderOnAddRemove disabled', function() { | ||
var rect1 = makeRect(), | ||
rect2 = makeRect(), | ||
originalRenderOnAddition, | ||
renderAllCount = 0; | ||
function countRenderAll() { | ||
renderAllCount++; | ||
} | ||
originalRenderOnAddition = canvas.renderOnAddRemove; | ||
canvas.renderOnAddRemove = false; | ||
canvas.on('after:render', countRenderAll); | ||
canvas.add(rect1, rect2); | ||
equal(renderAllCount, 0); | ||
equal(canvas.remove(rect1), rect1, 'should return removed object'); | ||
equal(renderAllCount, 0); | ||
equal(canvas.item(0), rect2, 'only second object should be left'); | ||
canvas.renderAll(); | ||
equal(renderAllCount, 1); | ||
canvas.off('after:render', countRenderAll); | ||
canvas.renderOnAddRemove = originalRenderOnAddition; | ||
}); | ||
test('sendToBack', function() { | ||
@@ -951,3 +1021,3 @@ ok(typeof canvas.sendToBack == 'function'); | ||
equal(canvas.getWidth(), 600); | ||
equal(canvas.setWidth(444), canvas, 'chainable'); | ||
equal(canvas.setWidth(444), canvas, 'should be chainable'); | ||
equal(canvas.getWidth(), 444); | ||
@@ -959,25 +1029,6 @@ }); | ||
equal(canvas.getHeight(), 600); | ||
equal(canvas.setHeight(765), canvas, 'chainable'); | ||
equal(canvas.setHeight(765), canvas, 'should be chainable'); | ||
equal(canvas.getHeight(), 765); | ||
}); | ||
// asyncTest('resizeImageToFit', function() { | ||
// ok(typeof canvas._resizeImageToFit == 'function'); | ||
// var imgEl = fabric.util.makeElement('img', { src: '../fixtures/very_large_image.jpg' }), | ||
// ORIGINAL_WIDTH = 3888, | ||
// ORIGINAL_HEIGHT = 2592; | ||
// setTimeout(function() { | ||
// equal(imgEl.width, ORIGINAL_WIDTH); | ||
// equal(imgEl.height, ORIGINAL_HEIGHT); | ||
// canvas._resizeImageToFit(imgEl); | ||
// ok(imgEl.width < ORIGINAL_WIDTH); | ||
// start(); | ||
// }, 2000); | ||
// }); | ||
asyncTest('fxRemove', function() { | ||
@@ -995,3 +1046,3 @@ ok(typeof canvas.fxRemove == 'function'); | ||
ok(canvas.item(0) === rect); | ||
ok(canvas.fxRemove(rect, { onComplete: onComplete }) === canvas, 'should be chainable'); | ||
equal(canvas.fxRemove(rect, { onComplete: onComplete }), canvas, 'should be chainable'); | ||
@@ -1031,28 +1082,2 @@ setTimeout(function() { | ||
test('object:added', function() { | ||
var objectsAdded = []; | ||
canvas.on('object:added', function(e) { | ||
objectsAdded.push(e.target); | ||
}); | ||
var rect = new fabric.Rect({ width: 10, height: 20 }); | ||
canvas.add(rect); | ||
deepEqual(objectsAdded[0], rect); | ||
var circle1 = new fabric.Circle(), | ||
circle2 = new fabric.Circle(); | ||
canvas.add(circle1, circle2); | ||
deepEqual(objectsAdded[1], circle1); | ||
deepEqual(objectsAdded[2], circle2); | ||
var circle3 = new fabric.Circle(); | ||
canvas.insertAt(circle3, 2); | ||
deepEqual(objectsAdded[3], circle3); | ||
}); | ||
})(); |
@@ -103,14 +103,21 @@ (function() { | ||
ok(typeof canvas.calcOffset == 'function', 'should respond to `calcOffset`'); | ||
equal(canvas, canvas.calcOffset()); | ||
equal(canvas.calcOffset(), canvas, 'should be chainable'); | ||
}); | ||
test('add', function() { | ||
var rect = makeRect(); | ||
var rect1 = makeRect(), | ||
rect2 = makeRect(), | ||
rect3 = makeRect(), | ||
rect4 = makeRect(); | ||
ok(typeof canvas.add == 'function'); | ||
ok(canvas === canvas.add(rect), 'should be chainable'); | ||
equal(canvas.item(0), rect); | ||
equal(canvas.add(rect1), canvas, 'should be chainable'); | ||
strictEqual(canvas.item(0), rect1); | ||
canvas.add(makeRect(), makeRect(), makeRect()); | ||
canvas.add(rect2, rect3, rect4); | ||
equal(canvas.getObjects().length, 4, 'should support multiple arguments'); | ||
strictEqual(canvas.item(1), rect2); | ||
strictEqual(canvas.item(2), rect3); | ||
strictEqual(canvas.item(3), rect4); | ||
}); | ||
@@ -128,8 +135,59 @@ | ||
canvas.insertAt(rect, 1); | ||
equal(canvas.item(1), rect); | ||
strictEqual(canvas.item(1), rect); | ||
canvas.insertAt(rect, 2); | ||
equal(canvas.item(2), rect); | ||
equal(canvas, canvas.insertAt(rect, 2), 'should be chainable'); | ||
strictEqual(canvas.item(2), rect); | ||
equal(canvas.insertAt(rect, 2), canvas, 'should be chainable'); | ||
}); | ||
test('remove', function() { | ||
var rect1 = makeRect(), | ||
rect2 = makeRect(), | ||
rect3 = makeRect(), | ||
rect4 = makeRect(); | ||
canvas.add(rect1, rect2, rect3, rect4); | ||
ok(typeof canvas.remove == 'function'); | ||
equal(canvas.remove(rect1), canvas, 'should be chainable'); | ||
strictEqual(canvas.item(0), rect2, 'should be second object'); | ||
canvas.remove(rect2, rect3); | ||
strictEqual(canvas.item(0), rect4); | ||
canvas.remove(rect4); | ||
equal(canvas.isEmpty(), true, 'canvas should be empty'); | ||
}); | ||
test('before:selection:cleared', function() { | ||
var isFired = false; | ||
canvas.on('before:selection:cleared', function() { isFired = true }); | ||
canvas.add(new fabric.Rect()); | ||
canvas.remove(canvas.item(0)); | ||
equal(isFired, false, 'removing inactive object shouldnt fire "before:selection:cleared"'); | ||
canvas.add(new fabric.Rect()); | ||
canvas.setActiveObject(canvas.item(0)); | ||
canvas.remove(canvas.item(0)); | ||
equal(isFired, true, 'removing active object should fire "before:selection:cleared"'); | ||
}); | ||
test('selection:cleared', function() { | ||
var isFired = false; | ||
canvas.on('selection:cleared', function() { isFired = true }); | ||
canvas.add(new fabric.Rect()); | ||
canvas.remove(canvas.item(0)); | ||
equal(isFired, false, 'removing inactive object shouldnt fire "selection:cleared"'); | ||
canvas.add(new fabric.Rect()); | ||
canvas.setActiveObject(canvas.item(0)); | ||
canvas.remove(canvas.item(0)); | ||
equal(isFired, true, 'removing active object should fire "selection:cleared"'); | ||
}); | ||
test('getContext', function() { | ||
@@ -141,3 +199,3 @@ ok(typeof canvas.getContext == 'function'); | ||
ok(typeof canvas.clearContext == 'function'); | ||
equal(canvas, canvas.clearContext(canvas.getContext()), 'chainable'); | ||
equal(canvas.clearContext(canvas.getContext()), canvas, 'should be chainable'); | ||
}); | ||
@@ -148,3 +206,3 @@ | ||
equal(canvas, canvas.clear()); | ||
equal(canvas.clear(), canvas, 'should be chainable'); | ||
equal(canvas.getObjects().length, 0); | ||
@@ -508,10 +566,2 @@ }); | ||
test('remove', function() { | ||
ok(typeof canvas.remove == 'function'); | ||
var rect1 = makeRect(), | ||
rect2 = makeRect(); | ||
canvas.add(rect1, rect2); | ||
equal(canvas.remove(rect1), rect1, 'should return removed object'); | ||
equal(canvas.item(0), rect2, 'only second object should be left'); | ||
}); | ||
@@ -688,3 +738,3 @@ test('sendToBack', function() { | ||
equal(canvas.setActiveGroup(group), canvas, 'chainable'); | ||
equal(canvas.setActiveGroup(group), canvas, 'should be chainable'); | ||
equal(canvas.getActiveGroup(), group); | ||
@@ -713,3 +763,3 @@ }); | ||
canvas.setActiveGroup(group); | ||
equal(canvas.discardActiveGroup(), canvas, 'chainable'); | ||
equal(canvas.discardActiveGroup(), canvas, 'should be chainable'); | ||
equal(canvas.getActiveGroup(), null, 'removing active group sets it to null'); | ||
@@ -877,3 +927,3 @@ }); | ||
equal(canvas.getWidth(), 600); | ||
equal(canvas.setWidth(444), canvas, 'chainable'); | ||
equal(canvas.setWidth(444), canvas, 'should be chainable'); | ||
equal(canvas.getWidth(), 444); | ||
@@ -885,3 +935,3 @@ }); | ||
equal(canvas.getHeight(), 600); | ||
equal(canvas.setHeight(765), canvas, 'chainable'); | ||
equal(canvas.setHeight(765), canvas, 'should be chainable'); | ||
equal(canvas.getHeight(), 765); | ||
@@ -918,21 +968,2 @@ }); | ||
// asyncTest('resizeImageToFit', function() { | ||
// ok(typeof canvas._resizeImageToFit == 'function'); | ||
// var imgEl = fabric.util.makeElement('img', { src: '../fixtures/very_large_image.jpg' }), | ||
// ORIGINAL_WIDTH = 3888, | ||
// ORIGINAL_HEIGHT = 2592; | ||
// setTimeout(function() { | ||
// equal(imgEl.width, ORIGINAL_WIDTH); | ||
// equal(imgEl.height, ORIGINAL_HEIGHT); | ||
// canvas._resizeImageToFit(imgEl); | ||
// ok(imgEl.width < ORIGINAL_WIDTH); | ||
// start(); | ||
// }, 2000); | ||
// }); | ||
asyncTest('fxRemove', function() { | ||
@@ -986,18 +1017,2 @@ ok(typeof canvas.fxRemove == 'function'); | ||
test('selection:cleared', function() { | ||
var isFired = false; | ||
canvas.on('selection:cleared', function() { isFired = true }); | ||
canvas.add(new fabric.Rect()); | ||
canvas.remove(canvas.item(0)); | ||
equal(isFired, false, 'removing inactive object shouldnt fire "selection:cleared"'); | ||
canvas.add(new fabric.Rect()); | ||
canvas.setActiveObject(canvas.item(0)); | ||
canvas.remove(canvas.item(0)); | ||
equal(isFired, true, 'removing active object should fire "selection:cleared"'); | ||
}); | ||
test('clipTo', function() { | ||
@@ -1004,0 +1019,0 @@ canvas.clipTo = function(ctx) { |
@@ -55,13 +55,31 @@ (function() { | ||
equal(group.getObjects().length, 2, 'should have 2 items'); | ||
deepEqual([ rect1, rect2 ], group.getObjects(), 'should return deepEqual objects as those passed to constructor'); | ||
deepEqual(group.getObjects(), [ rect1, rect2 ], 'should return deepEqual objects as those passed to constructor'); | ||
}); | ||
test('getObjects with type', function() { | ||
var rect = new fabric.Rect({ width: 10, height: 20 }), | ||
circle = new fabric.Circle({ radius: 30 }); | ||
var group = new fabric.Group([ rect, circle ]); | ||
equal(group.size(), 2, 'should have length=2 initially'); | ||
deepEqual(group.getObjects('rect'), [rect], 'should return rect only'); | ||
deepEqual(group.getObjects('circle'), [circle], 'should return circle only'); | ||
}); | ||
test('add', function() { | ||
var group = makeGroupWith2Objects(); | ||
var rect = new fabric.Rect(); | ||
var rect1 = new fabric.Rect(), | ||
rect2 = new fabric.Rect(), | ||
rect3 = new fabric.Rect(); | ||
ok(typeof group.add == 'function'); | ||
equal(group.add(rect), group, 'should be chainable'); | ||
equal(group.getObjects()[group.getObjects().length-1], rect, 'last object should be newly added one'); | ||
equal(group.add(rect1), group, 'should be chainable'); | ||
strictEqual(group.item(group.size()-1), rect1, 'last object should be newly added one'); | ||
equal(group.getObjects().length, 3, 'there should be 3 objects'); | ||
group.add(rect2, rect3); | ||
strictEqual(group.item(group.size()-1), rect3, 'last object should be last added one'); | ||
equal(group.size(), 5, 'there should be 5 objects'); | ||
}); | ||
@@ -76,4 +94,7 @@ | ||
ok(typeof group.remove == 'function'); | ||
equal(group.remove(rect2), rect2, 'should return removed object'); | ||
deepEqual([rect1, rect3], group.getObjects(), 'should remove object properly'); | ||
equal(group.remove(rect2), group, 'should be chainable'); | ||
deepEqual(group.getObjects(), [rect1, rect3], 'should remove object properly'); | ||
group.remove(rect1, rect3); | ||
equal(group.isEmpty(), true, 'group should be empty'); | ||
}); | ||
@@ -457,3 +478,3 @@ | ||
equal(group.item(2), rect2); | ||
equal(group, group.insertAt(rect1, 2), 'should be chainable'); | ||
equal(group.insertAt(rect1, 2), group, 'should be chainable'); | ||
}); | ||
@@ -460,0 +481,0 @@ |
@@ -903,2 +903,14 @@ (function(){ | ||
test('object:removed', function() { | ||
var object = new fabric.Object(); | ||
var removedEventFired = false; | ||
canvas.add(object); | ||
object.on('removed', function(){ removedEventFired = true; }); | ||
object.remove(); | ||
ok(removedEventFired); | ||
}); | ||
test('center', function() { | ||
@@ -905,0 +917,0 @@ var object = new fabric.Object(); |
@@ -479,2 +479,4 @@ (function() { | ||
stop(); | ||
var group1, group2; | ||
@@ -481,0 +483,0 @@ fabric.loadSVGFromString(SVG_WITH_1_ELEMENT, function(objects, options) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6682794
45519
223
15
+ Addedjsdom@0.8.11(transitive)
+ Addedxmlhttprequest@1.8.0(transitive)
- Removedcssom@0.2.5(transitive)
- Removedjsdom@0.7.0(transitive)
Updatedjsdom@0.8.x