diff --git a/src/editor/controller/initRender.js b/src/editor/controller/initRender.js index 00e8630..1de110c 100644 --- a/src/editor/controller/initRender.js +++ b/src/editor/controller/initRender.js @@ -195,14 +195,35 @@ define( return; } + // 放大 + if (e.keyCode == 187 && e.ctrlKey) { + e.originEvent.stopPropagation(); + e.originEvent.preventDefault(); + var size = render.getSize(); + render.scale(1.25, { + x: size.width / 2, + y: size.height / 2 + }); + } + // 缩小 + else if (e.keyCode == 189 && e.ctrlKey) { + e.originEvent.stopPropagation(); + e.originEvent.preventDefault(); + var size = render.getSize(); + render.scale(0.8, { + x: size.width / 2, + y: size.height / 2 + }); + } // 撤销 - if (e.keyCode == 90 && e.ctrlKey) { + else if (e.keyCode == 90 && e.ctrlKey) { me.execCommand('undo'); } // 恢复 else if (e.keyCode == 89 && e.ctrlKey) { me.execCommand('redo'); } + else { me.mode.keydown && me.mode.keydown.call(me, e); } diff --git a/src/editor/group/ShapesGroup.js b/src/editor/group/ShapesGroup.js index 764a8a9..3b2f054 100644 --- a/src/editor/group/ShapesGroup.js +++ b/src/editor/group/ShapesGroup.js @@ -88,6 +88,7 @@ define( this.editor.coverLayer.removeShape('bound'); + this.editor.coverLayer.removeShape('boundcenter'); delete this.bound; this.refresh(); diff --git a/src/editor/mode/bound.js b/src/editor/mode/bound.js index 13d8195..c906d82 100644 --- a/src/editor/mode/bound.js +++ b/src/editor/mode/bound.js @@ -33,7 +33,8 @@ define( if (result.length > 1) { shape = selectShape(result); } - this.setMode('shapes', [shape]); + + this.setMode('shapes', [shape], 'bound'); return; } diff --git a/src/editor/mode/range.js b/src/editor/mode/range.js index 834097a..ba687aa 100644 --- a/src/editor/mode/range.js +++ b/src/editor/mode/range.js @@ -74,7 +74,7 @@ define( if (bound.width >= 20 && bound.height >= 20) { var shapes; if ((shapes = selectShapes.call(this, bound))) { - this.setMode('shapes', shapes); + this.setMode('shapes', shapes, 'range'); return; } } diff --git a/src/editor/mode/shapes.js b/src/editor/mode/shapes.js index a14eecf..462fb8a 100644 --- a/src/editor/mode/shapes.js +++ b/src/editor/mode/shapes.js @@ -289,11 +289,16 @@ define( /** * 开始模式 */ - begin: function(shapes) { + begin: function(shapes, prevMode) { this.currentGroup = new ShapesGroup(shapes, this); this.currentGroup.refresh(); this.currentGroup.setMode('scale'); - this.clicked = false; + if (prevMode == 'bound') { + this.clicked = false; + } + else { + this.clicked = true; + } }, diff --git a/src/render/Render.js b/src/render/Render.js index cce10c4..8d5c84b 100644 --- a/src/render/Render.js +++ b/src/render/Render.js @@ -47,7 +47,9 @@ define( if(this.options.enableScale) { var me = this; this.capture.on('wheel', function(e) { - if (e.altKey) { + if (e.ctrlKey) { + e.originEvent.stopPropagation(); + e.originEvent.preventDefault(); var defaultRatio = me.options.defaultRatio || 1.2; var ratio = e.delta > 0 ? defaultRatio : 1 / defaultRatio; var toScale = me.camera.scale * ratio; @@ -154,10 +156,19 @@ define( * @return {this} */ Render.prototype.scale = function(ratio, p, noRefresh) { + + var toScale = this.camera.scale * ratio; + if ( + toScale < this.options.minScale + || toScale > this.options.maxScale + ) { + return; + } + this.camera.ratio = ratio; this.camera.center.x = p.x; this.camera.center.y = p.y; - this.camera.scale *= ratio; + this.camera.scale = toScale; if(true !== noRefresh) { this.painter.refresh(); diff --git a/src/render/capture/Keyboard.js b/src/render/capture/Keyboard.js index c569519..31d3ac7 100644 --- a/src/render/capture/Keyboard.js +++ b/src/render/capture/Keyboard.js @@ -47,7 +47,8 @@ define( ctrlKey: e.ctrlKey, metaKey: e.metaKey, altKey: e.altKey, - shiftKey: e.shiftKey + shiftKey: e.shiftKey, + originEvent: e }; }