mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-19 05:31:07 +00:00
Use toFixed to cutoff some of the values. Closes #352.
This commit is contained in:
parent
a1a54fea0b
commit
fcfe5052f8
2 changed files with 5 additions and 5 deletions
|
|
@ -151,18 +151,18 @@
|
|||
if (typeof options[prop] === 'string' && /^\d+%$/.test(options[prop])) {
|
||||
var percents = parseFloat(options[prop], 10);
|
||||
if (prop === 'x1' || prop === 'x2') {
|
||||
options[prop] = object.width * percents / 100;
|
||||
options[prop] = fabric.util.toFixed(object.width * percents / 100, 2);
|
||||
}
|
||||
else if (prop === 'y1' || prop === 'y2') {
|
||||
options[prop] = object.height * percents / 100;
|
||||
options[prop] = fabric.util.toFixed(object.height * percents / 100, 2);
|
||||
}
|
||||
}
|
||||
// normalize rendering point (should be from top/left corner rather than center of the shape)
|
||||
if (prop === 'x1' || prop === 'x2') {
|
||||
options[prop] -= object.width / 2;
|
||||
options[prop] -= fabric.util.toFixed(object.width / 2, 2);
|
||||
}
|
||||
else if (prop === 'y1' || prop === 'y2') {
|
||||
options[prop] -= object.height / 2;
|
||||
options[prop] -= fabric.util.toFixed(object.height / 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -529,7 +529,7 @@
|
|||
value *= -1;
|
||||
}
|
||||
else if (key === 'width' || key === 'height') {
|
||||
this.minScaleLimit = Math.min(0.1, 1/Math.max(this.width, this.height));
|
||||
this.minScaleLimit = toFixed(Math.min(0.1, 1/Math.max(this.width, this.height)), 2);
|
||||
}
|
||||
|
||||
this[key] = value;
|
||||
|
|
|
|||
Loading…
Reference in a new issue