mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-27 08:44:42 +00:00
Merge pull request #1861 from asturur/fix-control-padding
Fix controls padding
This commit is contained in:
commit
2fbebb03cc
1 changed files with 12 additions and 26 deletions
|
|
@ -308,8 +308,8 @@
|
|||
f = function (p) {
|
||||
return fabric.util.transformPoint(p, vpt);
|
||||
},
|
||||
w = this.width,
|
||||
h = this.height,
|
||||
w = this.width, currentWidth,
|
||||
h = this.height, currentHeight,
|
||||
capped = this.strokeLineCap === 'round' || this.strokeLineCap === 'square',
|
||||
vLine = this.type === 'line' && this.width === 0,
|
||||
hLine = this.type === 'line' && this.height === 0,
|
||||
|
|
@ -329,21 +329,21 @@
|
|||
if (strokeH) {
|
||||
h += h > 0 ? strokeWidth : -strokeWidth;
|
||||
}
|
||||
this.currentWidth = w * this.scaleX;
|
||||
this.currentHeight = h * this.scaleY;
|
||||
currentWidth = w * this.scaleX + 2 * this.padding;
|
||||
currentHeight = h * this.scaleY + 2 * this.padding;
|
||||
|
||||
// If width is negative, make postive. Fixes path selection issue
|
||||
if (this.currentWidth < 0) {
|
||||
this.currentWidth = Math.abs(this.currentWidth);
|
||||
if (currentWidth < 0) {
|
||||
currentWidth = Math.abs(currentWidth);
|
||||
}
|
||||
|
||||
var _hypotenuse = Math.sqrt(
|
||||
Math.pow(this.currentWidth / 2, 2) +
|
||||
Math.pow(this.currentHeight / 2, 2)),
|
||||
Math.pow(currentWidth / 2, 2) +
|
||||
Math.pow(currentHeight / 2, 2)),
|
||||
|
||||
_angle = Math.atan(
|
||||
isFinite(this.currentHeight / this.currentWidth)
|
||||
? this.currentHeight / this.currentWidth
|
||||
isFinite(currentHeight / currentWidth)
|
||||
? currentHeight / currentWidth
|
||||
: 0),
|
||||
|
||||
// offset added for rotate and scale actions
|
||||
|
|
@ -352,7 +352,7 @@
|
|||
sinTh = Math.sin(theta),
|
||||
cosTh = Math.cos(theta),
|
||||
coords = this.getCenterPoint(),
|
||||
wh = new fabric.Point(this.currentWidth, this.currentHeight),
|
||||
wh = new fabric.Point(currentWidth, currentHeight),
|
||||
_tl = new fabric.Point(coords.x - offsetX, coords.y - offsetY),
|
||||
_tr = new fabric.Point(_tl.x + (wh.x * cosTh), _tl.y + (wh.x * sinTh)),
|
||||
_bl = new fabric.Point(_tl.x - (wh.y * sinTh), _tl.y + (wh.y * cosTh)),
|
||||
|
|
@ -365,21 +365,7 @@
|
|||
mt = f(_mt),
|
||||
mr = f(new fabric.Point(_tr.x - (wh.y/2 * sinTh), _tr.y + (wh.y/2 * cosTh))),
|
||||
mb = f(new fabric.Point(_bl.x + (wh.x/2 * cosTh), _bl.y + (wh.x/2 * sinTh))),
|
||||
mtr = f(new fabric.Point(_mt.x, _mt.y)),
|
||||
|
||||
// padding
|
||||
padX = Math.cos(_angle + theta) * this.padding * Math.sqrt(2),
|
||||
padY = Math.sin(_angle + theta) * this.padding * Math.sqrt(2);
|
||||
|
||||
tl = tl.add(new fabric.Point(-padX, -padY));
|
||||
tr = tr.add(new fabric.Point(padY, -padX));
|
||||
br = br.add(new fabric.Point(padX, padY));
|
||||
bl = bl.add(new fabric.Point(-padY, padX));
|
||||
ml = ml.add(new fabric.Point((-padX - padY) / 2, (-padY + padX) / 2));
|
||||
mt = mt.add(new fabric.Point((padY - padX) / 2, -(padY + padX) / 2));
|
||||
mr = mr.add(new fabric.Point((padY + padX) / 2, (padY - padX) / 2));
|
||||
mb = mb.add(new fabric.Point((padX - padY) / 2, (padX + padY) / 2));
|
||||
mtr = mtr.add(new fabric.Point((padY - padX) / 2, -(padY + padX) / 2));
|
||||
mtr = f(new fabric.Point(_mt.x, _mt.y));
|
||||
|
||||
// debugging
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue