mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-21 20:01:52 +00:00
When free-drawing, do not create paths with 0 width/height, as they are rendered inconsistently across different browsers.
This commit is contained in:
parent
dd4f178389
commit
9bf3e71ced
1 changed files with 14 additions and 1 deletions
|
|
@ -843,7 +843,16 @@
|
|||
// TODO (kangax): maybe remove Path creation from here, to decouple fabric.Element from fabric.Path,
|
||||
// and instead fire something like "drawing:completed" event with path string
|
||||
|
||||
var p = new fabric.Path(path.join(''));
|
||||
path = path.join('');
|
||||
|
||||
if (path === "M 0 0 L 0 0 ") {
|
||||
// do not create 0 width/height paths, as they are rendered inconsistently across browsers
|
||||
// Firefox 4, for example, renders a dot, whereas Chrome 10 renders nothing
|
||||
return;
|
||||
}
|
||||
|
||||
var p = new fabric.Path(path);
|
||||
|
||||
p.fill = null;
|
||||
p.stroke = this.freeDrawingColor;
|
||||
p.strokeWidth = this.freeDrawingLineWidth;
|
||||
|
|
@ -1781,6 +1790,10 @@
|
|||
default:
|
||||
var klass = fabric[camelize(capitalize(obj.type))];
|
||||
if (klass && klass.fromObject) {
|
||||
// restore path
|
||||
if (path) {
|
||||
obj[pathProp] = path;
|
||||
}
|
||||
onObjectLoaded(klass.fromObject(obj), index);
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in a new issue