增加移动控制键
This commit is contained in:
parent
22f361f390
commit
283524152b
@ -48,7 +48,7 @@ define(
|
||||
/**
|
||||
* 根据控制点做图形变换
|
||||
*/
|
||||
ShapesGroup.prototype.beginTransform = function(point, camera) {
|
||||
ShapesGroup.prototype.beginTransform = function(point, camera, key) {
|
||||
this.bound = getBound(this.shapes);
|
||||
this.editor.coverLayer.addShape({
|
||||
id: 'bound',
|
||||
@ -63,9 +63,9 @@ define(
|
||||
/**
|
||||
* 根据控制点做图形变换
|
||||
*/
|
||||
ShapesGroup.prototype.transform = function(point, camera) {
|
||||
ShapesGroup.prototype.transform = function(point, camera, key) {
|
||||
if (this.mode === 'move') {
|
||||
moveTransform.call(this, camera);
|
||||
moveTransform.call(this, camera, key.altKey, key.shiftKey);
|
||||
}
|
||||
else if (this.mode === 'scale') {
|
||||
scaleTransform.call(this, point, camera);
|
||||
@ -78,12 +78,12 @@ define(
|
||||
/**
|
||||
* 刷新Shapesgroup信息
|
||||
*/
|
||||
ShapesGroup.prototype.finishTransform = function(point, camera) {
|
||||
ShapesGroup.prototype.finishTransform = function(point, camera, key) {
|
||||
|
||||
// 保存最后一次修改
|
||||
var coverShapes = this.coverShapes;
|
||||
this.coverShapes = this.shapes;
|
||||
this.transform(point, camera);
|
||||
this.transform(point, camera, key);
|
||||
this.coverShapes = coverShapes;
|
||||
delete this.bound;
|
||||
|
||||
|
@ -17,11 +17,13 @@ define(
|
||||
* 移动对象
|
||||
*
|
||||
* @param {Object} camera 镜头对象
|
||||
* @param {boolean} fixX 固定X
|
||||
* @param {boolean} fixY 固定Y
|
||||
*/
|
||||
function moveTransform (camera) {
|
||||
function moveTransform (camera, fixX, fixY) {
|
||||
|
||||
var x = camera.x - camera.startX;
|
||||
var y = camera.y - camera.startY;
|
||||
var x = fixX ? 0 : (camera.x - camera.startX);
|
||||
var y = fixY ? 0 : (camera.y - camera.startY);
|
||||
|
||||
// 更新shape
|
||||
var shapes = this.shapes;
|
||||
|
@ -70,6 +70,32 @@ define(
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'shapes_verticalalign',
|
||||
title: '垂直方向',
|
||||
items: [
|
||||
{
|
||||
name: 'shapes_verticalalign',
|
||||
type: 'ascent',
|
||||
title: '顶端对齐'
|
||||
},
|
||||
{
|
||||
name: 'shapes_verticalalign',
|
||||
type: 'middle',
|
||||
title: '居中对齐'
|
||||
},
|
||||
{
|
||||
name: 'shapes_verticalalign',
|
||||
type: 'descent',
|
||||
title: '低端对齐'
|
||||
},
|
||||
{
|
||||
name: 'shapes_verticalalign',
|
||||
type: 'baseline',
|
||||
title: '基线对齐'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'add_referenceline',
|
||||
title: '添加边界参考线'
|
||||
|
@ -203,7 +203,7 @@ define(
|
||||
|
||||
// 点拖动模式
|
||||
if (this.currentPoint) {
|
||||
this.currentGroup.beginTransform(this.currentPoint, this.render.camera);
|
||||
this.currentGroup.beginTransform(this.currentPoint, this.render.camera, e);
|
||||
}
|
||||
else {
|
||||
// 复制模式
|
||||
@ -218,7 +218,7 @@ define(
|
||||
}
|
||||
// 移动
|
||||
this.currentGroup.setMode('move');
|
||||
this.currentGroup.beginTransform(this.currentPoint, this.render.camera);
|
||||
this.currentGroup.beginTransform(this.currentPoint, this.render.camera, e);
|
||||
}
|
||||
|
||||
},
|
||||
@ -228,7 +228,7 @@ define(
|
||||
*/
|
||||
drag: function(e) {
|
||||
if(this.currentGroup) {
|
||||
this.currentGroup.transform(this.currentPoint, this.render.camera);
|
||||
this.currentGroup.transform(this.currentPoint, this.render.camera, e);
|
||||
}
|
||||
},
|
||||
|
||||
@ -238,12 +238,12 @@ define(
|
||||
dragend: function(e) {
|
||||
|
||||
if (this.currentPoint) {
|
||||
this.currentGroup.finishTransform(this.currentPoint, this.render.camera);
|
||||
this.currentGroup.finishTransform(this.currentPoint, this.render.camera, e);
|
||||
this.currentPoint = null;
|
||||
this.fire('change');
|
||||
}
|
||||
else if (this.currentGroup.mode == 'move') {
|
||||
this.currentGroup.finishTransform(this.currentPoint, this.render.camera);
|
||||
this.currentGroup.finishTransform(this.currentPoint, this.render.camera, e);
|
||||
this.currentGroup.setMode('scale');
|
||||
this.fire('change');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user