keepRatio property for Konva.Resizer

This commit is contained in:
Anton Lavrenov
2017-12-28 08:32:00 +07:00
parent 89d3dbc73a
commit 70deefd8aa
3 changed files with 46 additions and 30 deletions

View File

@@ -298,40 +298,46 @@
});
}
this.findOne('.top-left').position({
var keepRatio = this.keepRatio();
this.findOne('.top-left').setAttrs({
x: 0,
y: 0
});
this.findOne('.top-center').position({
this.findOne('.top-center').setAttrs({
x: width / 2,
y: 0
y: 0,
visible: !keepRatio
});
this.findOne('.top-right').position({
this.findOne('.top-right').setAttrs({
x: width,
y: 0
});
this.findOne('.middle-left').position({
this.findOne('.middle-left').setAttrs({
x: 0,
y: height / 2
y: height / 2,
visible: !keepRatio
});
this.findOne('.middle-right').position({
this.findOne('.middle-right').setAttrs({
x: width,
y: height / 2
y: height / 2,
visible: !keepRatio
});
this.findOne('.bottom-left').position({
this.findOne('.bottom-left').setAttrs({
x: 0,
y: height
});
this.findOne('.bottom-center').position({
this.findOne('.bottom-center').setAttrs({
x: width / 2,
y: height
y: height,
visible: !keepRatio
});
this.findOne('.bottom-right').position({
this.findOne('.bottom-right').setAttrs({
x: width,
y: height
});
this.findOne('.rotater').position({
this.findOne('.rotater').setAttrs({
x: width / 2,
y: -50
});
@@ -347,5 +353,7 @@
};
Konva.Util.extend(Konva.Resizer, Konva.Group);
Konva.Factory.addGetterSetter(Konva.Resizer, 'keepRatio', false);
Konva.Collection.mapMethods(Konva.Resizer);
})(Konva);