Fix rect positioning when loading from JSON. Closes #522

This commit is contained in:
kangax 2013-06-03 02:24:41 +02:00
parent 5a28acb032
commit 044f5ed483
7 changed files with 21 additions and 13 deletions

8
dist/all.js vendored
View file

@ -13080,8 +13080,8 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
this.callSuper('initialize', options);
this._initRxRy();
this.x = 0;
this.y = 0;
this.x = options.x || 0;
this.y = options.y || 0;
},
/**
@ -13190,7 +13190,9 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
toObject: function(propertiesToInclude) {
return extend(this.callSuper('toObject', propertiesToInclude), {
rx: this.get('rx') || 0,
ry: this.get('ry') || 0
ry: this.get('ry') || 0,
x: this.get('x'),
y: this.get('y')
});
},

4
dist/all.min.js vendored

File diff suppressed because one or more lines are too long

BIN
dist/all.min.js.gz vendored

Binary file not shown.

View file

@ -57,8 +57,8 @@
this.callSuper('initialize', options);
this._initRxRy();
this.x = 0;
this.y = 0;
this.x = options.x || 0;
this.y = options.y || 0;
},
/**
@ -167,7 +167,9 @@
toObject: function(propertiesToInclude) {
return extend(this.callSuper('toObject', propertiesToInclude), {
rx: this.get('rx') || 0,
ry: this.get('ry') || 0
ry: this.get('ry') || 0,
x: this.get('x'),
y: this.get('y')
});
},

View file

@ -29,7 +29,7 @@
var RECT_JSON = '{"objects":[{"type":"rect","originX":"center","originY":"center","left":0,"top":0,"width":10,"height":10,"fill":"rgb(0,0,0)","overlayFill":null,'+
'"stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,'+
'"selectable":true,"hasControls":true,"hasBorders":true,"hasRotatingPoint":true,"transparentCorners":true,"perPixelTargetFind":false,"shadow":null,'+
'"visible":true,"clipTo":null,"rx":0,"ry":0}],"background":"#ff5555"}';
'"visible":true,"clipTo":null,"rx":0,"ry":0,"x":0,"y":0}],"background":"#ff5555"}';
var el = fabric.document.createElement('canvas');
el.width = 600; el.height = 600;

View file

@ -27,12 +27,12 @@
var RECT_JSON = '{"objects":[{"type":"rect","originX":"center","originY":"center","left":0,"top":0,"width":10,"height":10,"fill":"rgb(0,0,0)","overlayFill":null,'+
'"stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,'+
'"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,"selectable":true,"hasControls":true,"hasBorders":true,"hasRotatingPoint":true,'+
'"transparentCorners":true,"perPixelTargetFind":false,"shadow":null,"visible":true,"clipTo":null,"rx":0,"ry":0}],"background":"#ff5555"}';
'"transparentCorners":true,"perPixelTargetFind":false,"shadow":null,"visible":true,"clipTo":null,"rx":0,"ry":0,"x":0,"y":0}],"background":"#ff5555"}';
var RECT_JSON_WITH_PADDING = '{"objects":[{"type":"rect","originX":"center","originY":"center","left":0,"top":0,"width":10,"height":20,"fill":"rgb(0,0,0)","overlayFill":null,'+
'"stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,'+
'"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,"selectable":true,"hasControls":true,"hasBorders":true,"hasRotatingPoint":true,'+
'"transparentCorners":true,"perPixelTargetFind":false,"shadow":null,"visible":true,"clipTo":null,"padding":123,"foo":"bar","rx":0,"ry":0}],"background":""}';
'"transparentCorners":true,"perPixelTargetFind":false,"shadow":null,"visible":true,"clipTo":null,"padding":123,"foo":"bar","rx":0,"ry":0,"x":0,"y":0}],"background":""}';
// force creation of static canvas
// TODO: fix this

View file

@ -32,7 +32,9 @@
'visible': true,
'clipTo': null,
'rx': 0,
'ry': 0
'ry': 0,
'x': 0,
'y': 0
};
QUnit.module('fabric.Rect');
@ -116,7 +118,9 @@
strokeLineJoin: 'bevil',
strokeMiterLimit: 5,
rx: 11,
ry: 12
ry: 12,
x: 10,
y: 20
});
deepEqual(rectWithAttrs.toObject(), expectedObject);
});