Commit 3d19060c authored by techird's avatar techird

抽取视野定位功能为 camera 命令

parent 8292538a
...@@ -23,7 +23,7 @@ $dependency = Array( ...@@ -23,7 +23,7 @@ $dependency = Array(
,'src/module/layout.default.js' ,'src/module/layout.default.js'
,'src/module/layout.bottom.js' ,'src/module/layout.bottom.js'
,'src/core/minder.select.js' ,'src/core/minder.select.js'
,'src/module/hand.js' ,'src/module/view.js'
,'src/module/dragtree.js' ,'src/module/dragtree.js'
,'src/module/dropfile.js' ,'src/module/dropfile.js'
,'src/module/keyboard.js' ,'src/module/keyboard.js'
......
...@@ -189,6 +189,7 @@ $( function () { ...@@ -189,6 +189,7 @@ $( function () {
function newFile() { function newFile() {
thisMapFilename = null; thisMapFilename = null;
window.km.importData( '新建脑图', 'plain' ); window.km.importData( '新建脑图', 'plain' );
window.km.execCommand( 'camera', window.km.getRoot() );
$user_btn.text( '<新建脑图>' ); $user_btn.text( '<新建脑图>' );
} }
......
...@@ -39,9 +39,9 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -39,9 +39,9 @@ var ViewDragger = kity.createClass( "ViewDragger", {
me.setStatus( 'hand' ); me.setStatus( 'hand' );
}, 1 ); }, 1 );
} }
} ); } )
this._minder.on( 'hand.beforemousedown', function ( e ) { .on( 'hand.beforemousedown', function ( e ) {
// 已经被用户打开拖放模式 // 已经被用户打开拖放模式
if ( dragger.isEnabled() ) { if ( dragger.isEnabled() ) {
lastPosition = e.getPosition(); lastPosition = e.getPosition();
...@@ -75,7 +75,7 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -75,7 +75,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
} }
} ); } );
KityMinder.registerModule( 'Hand', function () { KityMinder.registerModule( 'View', function () {
var km = this; var km = this;
...@@ -96,12 +96,24 @@ KityMinder.registerModule( 'Hand', function () { ...@@ -96,12 +96,24 @@ KityMinder.registerModule( 'Hand', function () {
} }
} ); } );
var CameraCommand = kity.createClass( "CameraCommand", {
base: Command,
execute: function ( km, focusNode ) {
var viewport = km.getPaper().getViewPort();
var offset = focusNode.getRenderContainer().getRenderBox( km.getRenderContainer() );
var dx = viewport.center.x - offset.x - offset.width / 2,
dy = viewport.center.y - offset.y;
km.getRenderContainer().fxTranslate( dx, dy, 1000, "easeOutQuint" );
}
} );
return { return {
init: function () { init: function () {
this._viewDragger = new ViewDragger( this ); this._viewDragger = new ViewDragger( this );
}, },
commands: { commands: {
'hand': ToggleHandCommand 'hand': ToggleHandCommand,
'camera': CameraCommand
}, },
events: { events: {
keyup: function ( e ) { keyup: function ( e ) {
...@@ -113,7 +125,7 @@ KityMinder.registerModule( 'Hand', function () { ...@@ -113,7 +125,7 @@ KityMinder.registerModule( 'Hand', function () {
mousewheel: function ( e ) { mousewheel: function ( e ) {
var dx, dy; var dx, dy;
e = e.originEvent; e = e.originEvent;
if(e.ctrlKey || e.shiftKey) return; if ( e.ctrlKey || e.shiftKey ) return;
if ( 'wheelDeltaX' in e ) { if ( 'wheelDeltaX' in e ) {
...@@ -136,12 +148,7 @@ KityMinder.registerModule( 'Hand', function () { ...@@ -136,12 +148,7 @@ KityMinder.registerModule( 'Hand', function () {
}, },
'normal.dblclick': function ( e ) { 'normal.dblclick': function ( e ) {
if ( e.getTargetNode() ) return; if ( e.getTargetNode() ) return;
this.execCommand( 'camera', this.getRoot() );
var viewport = this.getPaper().getViewPort();
var offset = this.getRoot().getRenderContainer().getRenderBox( this.getRenderContainer() );
var dx = viewport.center.x - offset.x - offset.width / 2,
dy = viewport.center.y - offset.y;
this.getRenderContainer().fxTranslate( dx, dy, 1000, "easeOutQuint" );
} }
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment