Commit 372f807a authored by techird's avatar techird

Merge branch 'dev'

parents b8d15e83 ef8365bc
[submodule "kity"] [submodule "kity"]
path = kity path = kity
url = https://github.com/kitygraph/kity.git url = git@github.com:fex-team/kity.git
...@@ -4,7 +4,7 @@ Kity Minder ...@@ -4,7 +4,7 @@ Kity Minder
## 简介 ## 简介
KityMinder 是百度 FEX 团队的 f-cube 小组(原UEditor小组)的又一力作。作为一款在线的脑图编辑工具,它有着很多Native编辑工具的交互体验。KM与UE有着一样的宗旨,就是注重最终用户的使用体验。同时,它充分发挥了Web云存储的优势,可以直接将编辑中的脑图同步到云端。此外,借由独创的 “云盘分享”功能,用户可以一键将当前编辑的脑图直接生成在线链接共享给其他用户,实现无缝沟通。 KityMinder 是百度 FEX 团队的 f-cube 小组(原UEditor小组)的又一力作。作为一款在线的脑图编辑工具,它有着很多Native编辑工具的交互体验。KM与UE有着一样的宗旨,就是注重最终用户的使用体验。同时,它充分发挥了Web云存储的优势,可以直接将编辑中的脑图同步到云端。此外,借由独创的 “云盘分享”功能,用户可以一键将当前编辑的脑图直接生成在线链接共享给其他用户,实现无缝沟通。
![Alt text](summary.jpg "简介图") ![KityMinder](summary.jpg "KityMinder 界面")
KM是基于SVG技术实现,使用JavaScript+html实现。支持绝大多数的主流浏览器。 KM是基于SVG技术实现,使用JavaScript+html实现。支持绝大多数的主流浏览器。
支持列表如下 支持列表如下
...@@ -14,9 +14,34 @@ KM是基于SVG技术实现,使用JavaScript+html实现。支持绝大多数的 ...@@ -14,9 +14,34 @@ KM是基于SVG技术实现,使用JavaScript+html实现。支持绝大多数的
3. Safari 3. Safari
4. IE9+ 4. IE9+
## 线上版本
[http://naotu.baidu.com](http://naotu.baidu.com)
## 项目链接 注意:由于历史原因,有两个发布过的公开地址:
[直接使用链接](http://fex-team.github.io/kityminder/dist/)
1. [~~http://fex-team.baidu.com/kityminder/dist~~](http://fex-team.baidu.com/kityminder/dist)
2. [~~http://kitygraph.github.io/kityminder/dist~~](http://kitygraph.github.io/kityminder/dist)
3. [http://fex.baidu.com/kityminder/dist](http://fex.baidu.com/kityminder/dist)
第 1 个地址已经失效;
第 2 个地址不再维护更新,不便之处;
第 3 个地址会是最新发布的版本;
新地址已经稳定,请大家放心使用。地址变动频繁带来的不便,请谅解。
## 依赖说明
KityMinder 依赖 Kity 库。刚下载的压缩包或者刚从 github 拉下来的代码会有一个空的 kity 目录。要运行调试,必须加载 Kity 的依赖:
1. 如果你下载的是 KityMinder 的压缩包,那么需要手动下载 [Kity](http://kitygraph.github.io/kityminder/kity/dist/kitygraph.all.js) 库到 kity/dist/kitygraph.all.js
2. 如果你是从 github 上拉源代码下来的,那么可以更新一下子模块:
```bash
cd YOUR_KITYMINDER_PATH
git submodule init
git submodule update
```
## 联系我们 ## 联系我们
邮件: kity@baidu.com 邮件: kity@baidu.com
......
...@@ -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'
......
...@@ -27,6 +27,6 @@ ...@@ -27,6 +27,6 @@
<body> <body>
<div id="kityminder" onselectstart="return false"></div> <div id="kityminder" onselectstart="return false"></div>
<body> </body>
</html> </html>
\ No newline at end of file
#github-url{position:absolute;width:130px;height:130px;right:-90px;top:60px;background-color:#fff;border-radius:65px;box-shadow:-3px 1px 10px rgba(0,0,0,0.3);-webkit-transition:all .2s ease;-moz-transition:all .2s ease;-ms-transition:all .2s ease;transition:all .2s ease;opacity:.3;cursor:pointer}#github-url:hover{-webkit-transform:translate(-280px);-moz-transform:translate(-280px);-ms-transform:translate(-280px);transform:translate(-280px);opacity:1}
#github-url:before{content:' ';display:block;position:absolute;width:300px;height:130px;left:65px;top:0;background:rgba(0,0,0,0.001)}
#github-url:after{content:' ';display:block;position:absolute;width:130px;height:130px;background:url(../img/github_mark.png) no-repeat 5px 4px}
#github-url a{display:block;position:absolute;top:40px;font-size:18px;width:300px;height:40px;padding:10px 0 10px 20px;line-height:40px;color:#000;left:120px;border-radius:0 25px 25px 0;background-color:#fff}
#about{position:absolute;bottom:10px;right:10px;height:24px;line-height:24px;color:#888;font-family:Arial;font-size:13px;font-weight:normal;margin:0;text-shadow:0 1px 1px #000}#about a{color:#888}#about a:hover{color:#fff}
@bg: #FFF;
#github-url {
position: absolute;
width: 130px;
height: 130px;
right: -90px;
top: 60px;
background-color: @bg;
border-radius: 65px;
box-shadow: -3px 1px 10px rgba(0,0,0,.3);
-webkit-transition: all .2s ease;
-moz-transition: all .2s ease;
-ms-transition: all .2s ease;
transition: all .2s ease;
opacity: .3;
cursor: pointer;
&:hover {
-webkit-transform: translate(-280px);
-moz-transform: translate(-280px);
-ms-transform: translate(-280px);
transform: translate(-280px);
opacity: 1;
}
&:before {
content: ' ';
display: block;
position: absolute;
width: 300px;
height: 130px;
left: 65px;
top: 0;
background: rgba(0,0,0,0.001);
}
&:after {
content: ' ';
display: block;
position: absolute;
width: 130px;
height: 130px;
background: url(../img/github_mark.png) no-repeat 5px 4px;
}
a {
display: block;
position: absolute;
top: 40px;
font-size: 18px;
width: 300px;
height: 40px;
padding: 10px 0 10px 20px;
line-height: 40px;
color: black;
left: 120px;
border-radius: 0 25px 25px 0;
background-color: @bg;
}
}
#about {
position: absolute;
bottom: 10px;
right: 10px;
height: 24px;
line-height: 24px;
color: #888;
font-family: Arial;
font-size: 13px;
font-weight: normal;
margin: 0;
text-shadow: 0 1px 1px black;
a {
color: #888;
&:hover {
color: white;
}
}
}
\ No newline at end of file
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
<link href="../themes/default/css/import.css" type="text/css" rel="stylesheet" /> <link href="../themes/default/css/import.css" type="text/css" rel="stylesheet" />
<link href="../dialogs/dialogs.css" rel="stylesheet" type="text/css" /> <link href="../dialogs/dialogs.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/links.css" />
<script> <script>
$(function () { $(function () {
// create km instance // create km instance
...@@ -27,6 +29,14 @@ ...@@ -27,6 +29,14 @@
<body> <body>
<div id="kityminder" onselectstart="return false"></div> <div id="kityminder" onselectstart="return false"></div>
<body> <div id="github-url">
<a href="https://github.com/fex-team/kityminder.git" target="_blank">Fork me on Github</a>
</div>
<p id="about">
Powered by f-cube, <a href="http://fex.baidu.com" target="_blank">FEX</a> |
<a href="https://github.com/fex-team/kityminder/issues/new" target="_blank">Report a Bug</a> |
<a href="mailto:kity@baidu.com" target="_blank">Contact Us</a>
</p>
</body>
</html> </html>
\ No newline at end of file
/*! /*!
* ==================================================== * ====================================================
* kityminder - v1.0.0 - 2014-03-07 * kityminder - v1.0.0 - 2014-03-10
* https://github.com/fex-team/kityminder * https://github.com/fex-team/kityminder
* GitHub: https://github.com/fex-team/kityminder.git * GitHub: https://github.com/fex-team/kityminder.git
* Copyright (c) 2014 f-cube @ FEX; Licensed MIT * Copyright (c) 2014 f-cube @ FEX; Licensed MIT
...@@ -3477,9 +3477,9 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -3477,9 +3477,9 @@ var ViewDragger = kity.createClass( "ViewDragger", {
dragger.setEnabled( true ); dragger.setEnabled( true );
isRootDrag = true; isRootDrag = true;
var me = this; var me = this;
setTimeout(function() { setTimeout( function () {
me.setStatus('hand'); me.setStatus( 'hand' );
}, 1); }, 1 );
} }
} ); } );
...@@ -3553,21 +3553,37 @@ KityMinder.registerModule( 'Hand', function () { ...@@ -3553,21 +3553,37 @@ KityMinder.registerModule( 'Hand', function () {
} }
}, },
mousewheel: function ( e ) { mousewheel: function ( e ) {
var dx = e.originEvent.wheelDeltaX || 0, var dx, dy;
dy = e.originEvent.wheelDeltaY || e.originEvent.wheelDelta; e = e.originEvent;
if(e.ctrlKey || e.shiftKey) return;
if ( 'wheelDeltaX' in e ) {
dx = e.wheelDeltaX || 0;
dy = e.wheelDeltaY || 0;
} else {
dx = 0;
dy = e.wheelDelta;
}
this._viewDragger.move( { this._viewDragger.move( {
x: dx / 2.5, x: dx / 2.5,
y: dy / 2.5 y: dy / 2.5
} ); } );
e.originEvent.preventDefault(); e.preventDefault();
}, },
dblclick: function () { 'normal.dblclick': function ( e ) {
if ( e.getTargetNode() ) return;
var viewport = this.getPaper().getViewPort(); var viewport = this.getPaper().getViewPort();
var offset = this.getRoot().getRenderContainer( this.getRenderContainer() ).getTransform().getTranslate(); var offset = this.getRoot().getRenderContainer().getRenderBox( this.getRenderContainer() );
var dx = viewport.center.x - offset.x, var dx = viewport.center.x - offset.x - offset.width / 2,
dy = viewport.center.y - offset.y; dy = viewport.center.y - offset.y;
//this.getRenderContainer().fxTranslate(dx, dy, 300); this.getRenderContainer().fxTranslate( dx, dy, 1000, "easeOutQuint" );
} }
} }
}; };
...@@ -5012,7 +5028,7 @@ KityMinder.registerModule( "fontmodule", function () { ...@@ -5012,7 +5028,7 @@ KityMinder.registerModule( "fontmodule", function () {
KityMinder.registerModule( 'Zoom', function () { KityMinder.registerModule( 'Zoom', function () {
var MAX_ZOOM = 2, var MAX_ZOOM = 2,
MIN_ZOOM = 0.5, MIN_ZOOM = kity.Browser.chrome ? 1 : 0.5,
ZOOM_STEP = Math.sqrt( 2 ); ZOOM_STEP = Math.sqrt( 2 );
function zoom( minder, rate ) { function zoom( minder, rate ) {
...@@ -5040,31 +5056,31 @@ KityMinder.registerModule( 'Zoom', function () { ...@@ -5040,31 +5056,31 @@ KityMinder.registerModule( 'Zoom', function () {
} }
} ); } );
animator.start( paper, 100, 'ease' ); animator.start( paper, 500, 'ease' );
minder._zoomValue = zoomValue *= rate; minder._zoomValue = zoomValue *= rate;
} }
var ZoomInCommand = kity.createClass( 'ZoomInCommand', { var ZoomInCommand = kity.createClass( 'ZoomInCommand', {
base: Command, base: Command,
execute: function ( minder ) { execute: function ( minder ) {
if( !this.queryState( minder ) ) { if ( !this.queryState( minder ) ) {
zoom( minder, 1 / ZOOM_STEP ); zoom( minder, 1 / ZOOM_STEP );
} }
}, },
queryState: function ( minder ) { queryState: function ( minder ) {
return (minder._zoomValue > MIN_ZOOM) ? 0 : -1; return ( minder._zoomValue > 1 / MAX_ZOOM ) ? 0 : -1;
} }
} ); } );
var ZoomOutCommand = kity.createClass( 'ZoomOutCommand', { var ZoomOutCommand = kity.createClass( 'ZoomOutCommand', {
base: Command, base: Command,
execute: function ( minder ) { execute: function ( minder ) {
if( !this.queryState( minder ) ) { if ( !this.queryState( minder ) ) {
zoom( minder, ZOOM_STEP ); zoom( minder, ZOOM_STEP );
} }
}, },
queryState: function ( minder ) { queryState: function ( minder ) {
return (minder._zoomValue < MAX_ZOOM) ? 0 : -1; return ( minder._zoomValue < 1 / MIN_ZOOM ) ? 0 : -1;
} }
} ); } );
...@@ -5076,26 +5092,30 @@ KityMinder.registerModule( 'Zoom', function () { ...@@ -5076,26 +5092,30 @@ KityMinder.registerModule( 'Zoom', function () {
events: { events: {
'normal.keydown':function(e){ 'normal.keydown': function ( e ) {
var me = this; var me = this;
var originEvent = e.originEvent; var originEvent = e.originEvent;
var keyCode = originEvent.keyCode || originEvent.which; var keyCode = originEvent.keyCode || originEvent.which;
if(keymap['='] == keyCode){ if ( keymap[ '=' ] == keyCode ) {
me.execCommand('zoom-in'); me.execCommand( 'zoom-in' );
} }
if(keymap['-'] == keyCode){ if ( keymap[ '-' ] == keyCode ) {
me.execCommand('zoom-out'); me.execCommand( 'zoom-out' );
} }
}, },
'ready': function () { 'ready': function () {
this._zoomValue = 1; this._zoomValue = 1;
}, },
// disable mouse wheel 'normal.mousewheel': function ( e ) {
'mousewheel_': function ( e ) { if ( !e.originEvent.ctrlKey ) return;
var delta = e.originEvent.wheelDelta; var delta = e.originEvent.wheelDelta;
var me = this; var me = this;
if ( !kity.Browser.mac ) {
delta = -delta;
}
// 稀释 // 稀释
if ( Math.abs( delta ) > 100 ) { if ( Math.abs( delta ) > 100 ) {
clearTimeout( this._wheelZoomTimeout ); clearTimeout( this._wheelZoomTimeout );
...@@ -5107,9 +5127,9 @@ KityMinder.registerModule( 'Zoom', function () { ...@@ -5107,9 +5127,9 @@ KityMinder.registerModule( 'Zoom', function () {
var value; var value;
var lastValue = me.getPaper()._zoom || 1; var lastValue = me.getPaper()._zoom || 1;
if ( delta < 0 ) { if ( delta < 0 ) {
me.execCommand('zoom-in'); me.execCommand( 'zoom-in' );
} else if ( delta > 0 ) { } else if ( delta > 0 ) {
me.execCommand('zoom-out'); me.execCommand( 'zoom-out' );
} }
}, 100 ); }, 100 );
...@@ -7580,6 +7600,9 @@ KityMinder.registerProtocal( "png", function () { ...@@ -7580,6 +7600,9 @@ KityMinder.registerProtocal( "png", function () {
renderContainer.translate( -renderBox.x, -renderBox.y ); renderContainer.translate( -renderBox.x, -renderBox.y );
svgXml = km.getPaper().container.innerHTML; svgXml = km.getPaper().container.innerHTML;
renderContainer.translate( renderBox.x, renderBox.y );
$svg = $( svgXml ); $svg = $( svgXml );
$svg.attr( { $svg.attr( {
width: renderBox.width, width: renderBox.width,
...@@ -7627,7 +7650,6 @@ KityMinder.registerProtocal( "png", function () { ...@@ -7627,7 +7650,6 @@ KityMinder.registerProtocal( "png", function () {
downloadUrl = generateDataUrl( canvas ); downloadUrl = generateDataUrl( canvas );
if ( finishCallback ) { if ( finishCallback ) {
finishCallback( downloadUrl ); finishCallback( downloadUrl );
renderContainer.translate( renderBox.x, renderBox.y );
} }
} ); } );
} ); } );
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Subproject commit 26f9836718affd92c95196be698b14b1c6da4a95 Subproject commit e144ccd9270712497804915d13ec92f6593299b0
git stash
git checkout gh-pages
git merge dev -m "merge from dev"
grunt
git commit -am "publish"
git push origin gh-pages
git checkout dev
git stash pop
...@@ -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( '<新建脑图>' );
} }
...@@ -237,7 +238,8 @@ $( function () { ...@@ -237,7 +238,8 @@ $( function () {
var data = window.km.exportData( 'json' ); var data = window.km.exportData( 'json' );
$share_btn.loading( '正在分享...' ); $share_btn.loading( '正在分享...' );
var shareUrl = baseUrl + 'index.html?share_id=' + share_id; var currentUrl = window.location.origin + window.location.pathname;
var shareUrl = currentUrl + '?share_id=' + share_id;
share( data, share_id, function ( success ) { share( data, share_id, function ( success ) {
if ( success ) { if ( success ) {
var $popup = $( '<div></div>' ).addClass( 'popup' ).appendTo( 'body' ); var $popup = $( '<div></div>' ).addClass( 'popup' ).appendTo( 'body' );
......
...@@ -13,7 +13,7 @@ kity.extendClass( Minder, { ...@@ -13,7 +13,7 @@ kity.extendClass( Minder, {
}, },
// TODO: mousemove lazy bind // TODO: mousemove lazy bind
_bindPaperEvents: function () { _bindPaperEvents: function () {
this._paper.on( 'click dblclick mousedown contextmenu mouseup mousemove mousewheel touchstart touchmove touchend', this._firePharse.bind( this ) ); this._paper.on( 'click dblclick mousedown contextmenu mouseup mousemove mousewheel DOMMouseScroll touchstart touchmove touchend', this._firePharse.bind( this ) );
if ( window ) { if ( window ) {
window.addEventListener( 'resize', this._firePharse.bind( this ) ); window.addEventListener( 'resize', this._firePharse.bind( this ) );
} }
...@@ -27,6 +27,10 @@ kity.extendClass( Minder, { ...@@ -27,6 +27,10 @@ kity.extendClass( Minder, {
_firePharse: function ( e ) { _firePharse: function ( e ) {
var beforeEvent, preEvent, executeEvent; var beforeEvent, preEvent, executeEvent;
if ( e.type == 'DOMMouseScroll' ) {
e.type = 'mousewheel';
e.wheelDelta = e.originEvent.wheelDelta = e.originEvent.detail * 120;
}
beforeEvent = new MinderEvent( 'before' + e.type, e, true ); beforeEvent = new MinderEvent( 'before' + e.type, e, true );
if ( this._fire( beforeEvent ) ) { if ( this._fire( beforeEvent ) ) {
...@@ -67,14 +71,14 @@ kity.extendClass( Minder, { ...@@ -67,14 +71,14 @@ kity.extendClass( Minder, {
var callbacks = this._eventCallbacks[ e.type.toLowerCase() ] || []; var callbacks = this._eventCallbacks[ e.type.toLowerCase() ] || [];
if(status){ if ( status ) {
callbacks = callbacks.concat(this._eventCallbacks[ status + '.' + e.type.toLowerCase() ] || []); callbacks = callbacks.concat( this._eventCallbacks[ status + '.' + e.type.toLowerCase() ] || [] );
} }
if(callbacks.length == 0){ if ( callbacks.length === 0 ) {
return; return;
} }
var lastStatus = this.getStatus(); var lastStatus = this.getStatus();
...@@ -92,14 +96,14 @@ kity.extendClass( Minder, { ...@@ -92,14 +96,14 @@ kity.extendClass( Minder, {
}, },
on: function ( name, callback ) { on: function ( name, callback ) {
var km = this; var km = this;
utils.each(name.split(/\s+/),function(i,n){ utils.each( name.split( /\s+/ ), function ( i, n ) {
km._listen( n.toLowerCase(), callback ); km._listen( n.toLowerCase(), callback );
}); } );
return this; return this;
}, },
off: function ( name, callback ) { off: function ( name, callback ) {
var types = name.split( /\s+/); var types = name.split( /\s+/ );
var i, j, callbacks, removeIndex; var i, j, callbacks, removeIndex;
for ( i = 0; i < types.length; i++ ) { for ( i = 0; i < types.length; i++ ) {
......
...@@ -35,13 +35,13 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -35,13 +35,13 @@ var ViewDragger = kity.createClass( "ViewDragger", {
dragger.setEnabled( true ); dragger.setEnabled( true );
isRootDrag = true; isRootDrag = true;
var me = this; var me = this;
setTimeout(function() { setTimeout( function () {
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 ) {
...@@ -111,21 +123,32 @@ KityMinder.registerModule( 'Hand', function () { ...@@ -111,21 +123,32 @@ KityMinder.registerModule( 'Hand', function () {
} }
}, },
mousewheel: function ( e ) { mousewheel: function ( e ) {
var dx = e.originEvent.wheelDeltaX || 0, var dx, dy;
dy = e.originEvent.wheelDeltaY || e.originEvent.wheelDelta; e = e.originEvent;
if ( e.ctrlKey || e.shiftKey ) return;
if ( 'wheelDeltaX' in e ) {
dx = e.wheelDeltaX || 0;
dy = e.wheelDeltaY || 0;
} else {
dx = 0;
dy = e.wheelDelta;
}
this._viewDragger.move( { this._viewDragger.move( {
x: dx / 2.5, x: dx / 2.5,
y: dy / 2.5 y: dy / 2.5
} ); } );
e.originEvent.preventDefault(); e.preventDefault();
}, },
dblclick: function () { 'normal.dblclick': function ( e ) {
var viewport = this.getPaper().getViewPort(); if ( e.getTargetNode() ) return;
var offset = this.getRoot().getRenderContainer( this.getRenderContainer() ).getTransform().getTranslate(); this.execCommand( 'camera', this.getRoot() );
var dx = viewport.center.x - offset.x,
dy = viewport.center.y - offset.y;
//this.getRenderContainer().fxTranslate(dx, dy, 300);
} }
} }
}; };
......
KityMinder.registerModule( 'Zoom', function () { KityMinder.registerModule( 'Zoom', function () {
var MAX_ZOOM = 2, var MAX_ZOOM = 2,
MIN_ZOOM = 0.5, MIN_ZOOM = kity.Browser.chrome ? 1 : 0.5,
ZOOM_STEP = Math.sqrt( 2 ); ZOOM_STEP = Math.sqrt( 2 );
function zoom( minder, rate ) { function zoom( minder, rate ) {
...@@ -28,31 +28,31 @@ KityMinder.registerModule( 'Zoom', function () { ...@@ -28,31 +28,31 @@ KityMinder.registerModule( 'Zoom', function () {
} }
} ); } );
animator.start( paper, 100, 'ease' ); animator.start( paper, 500, 'ease' );
minder._zoomValue = zoomValue *= rate; minder._zoomValue = zoomValue *= rate;
} }
var ZoomInCommand = kity.createClass( 'ZoomInCommand', { var ZoomInCommand = kity.createClass( 'ZoomInCommand', {
base: Command, base: Command,
execute: function ( minder ) { execute: function ( minder ) {
if( !this.queryState( minder ) ) { if ( !this.queryState( minder ) ) {
zoom( minder, 1 / ZOOM_STEP ); zoom( minder, 1 / ZOOM_STEP );
} }
}, },
queryState: function ( minder ) { queryState: function ( minder ) {
return (minder._zoomValue > MIN_ZOOM) ? 0 : -1; return ( minder._zoomValue > 1 / MAX_ZOOM ) ? 0 : -1;
} }
} ); } );
var ZoomOutCommand = kity.createClass( 'ZoomOutCommand', { var ZoomOutCommand = kity.createClass( 'ZoomOutCommand', {
base: Command, base: Command,
execute: function ( minder ) { execute: function ( minder ) {
if( !this.queryState( minder ) ) { if ( !this.queryState( minder ) ) {
zoom( minder, ZOOM_STEP ); zoom( minder, ZOOM_STEP );
} }
}, },
queryState: function ( minder ) { queryState: function ( minder ) {
return (minder._zoomValue < MAX_ZOOM) ? 0 : -1; return ( minder._zoomValue < 1 / MIN_ZOOM ) ? 0 : -1;
} }
} ); } );
...@@ -64,26 +64,30 @@ KityMinder.registerModule( 'Zoom', function () { ...@@ -64,26 +64,30 @@ KityMinder.registerModule( 'Zoom', function () {
events: { events: {
'normal.keydown':function(e){ 'normal.keydown': function ( e ) {
var me = this; var me = this;
var originEvent = e.originEvent; var originEvent = e.originEvent;
var keyCode = originEvent.keyCode || originEvent.which; var keyCode = originEvent.keyCode || originEvent.which;
if(keymap['='] == keyCode){ if ( keymap[ '=' ] == keyCode ) {
me.execCommand('zoom-in'); me.execCommand( 'zoom-in' );
} }
if(keymap['-'] == keyCode){ if ( keymap[ '-' ] == keyCode ) {
me.execCommand('zoom-out'); me.execCommand( 'zoom-out' );
} }
}, },
'ready': function () { 'ready': function () {
this._zoomValue = 1; this._zoomValue = 1;
}, },
// disable mouse wheel 'normal.mousewheel': function ( e ) {
'mousewheel_': function ( e ) { if ( !e.originEvent.ctrlKey ) return;
var delta = e.originEvent.wheelDelta; var delta = e.originEvent.wheelDelta;
var me = this; var me = this;
if ( !kity.Browser.mac ) {
delta = -delta;
}
// 稀释 // 稀释
if ( Math.abs( delta ) > 100 ) { if ( Math.abs( delta ) > 100 ) {
clearTimeout( this._wheelZoomTimeout ); clearTimeout( this._wheelZoomTimeout );
...@@ -95,9 +99,9 @@ KityMinder.registerModule( 'Zoom', function () { ...@@ -95,9 +99,9 @@ KityMinder.registerModule( 'Zoom', function () {
var value; var value;
var lastValue = me.getPaper()._zoom || 1; var lastValue = me.getPaper()._zoom || 1;
if ( delta < 0 ) { if ( delta < 0 ) {
me.execCommand('zoom-in'); me.execCommand( 'zoom-in' );
} else if ( delta > 0 ) { } else if ( delta > 0 ) {
me.execCommand('zoom-out'); me.execCommand( 'zoom-out' );
} }
}, 100 ); }, 100 );
......
...@@ -31,6 +31,9 @@ KityMinder.registerProtocal( "png", function () { ...@@ -31,6 +31,9 @@ KityMinder.registerProtocal( "png", function () {
renderContainer.translate( -renderBox.x, -renderBox.y ); renderContainer.translate( -renderBox.x, -renderBox.y );
svgXml = km.getPaper().container.innerHTML; svgXml = km.getPaper().container.innerHTML;
renderContainer.translate( renderBox.x, renderBox.y );
$svg = $( svgXml ); $svg = $( svgXml );
$svg.attr( { $svg.attr( {
width: renderBox.width, width: renderBox.width,
...@@ -78,7 +81,6 @@ KityMinder.registerProtocal( "png", function () { ...@@ -78,7 +81,6 @@ KityMinder.registerProtocal( "png", function () {
downloadUrl = generateDataUrl( canvas ); downloadUrl = generateDataUrl( canvas );
if ( finishCallback ) { if ( finishCallback ) {
finishCallback( downloadUrl ); finishCallback( downloadUrl );
renderContainer.translate( renderBox.x, renderBox.y );
} }
} ); } );
} ); } );
......
...@@ -3,9 +3,10 @@ html, body, div { ...@@ -3,9 +3,10 @@ html, body, div {
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
html, body, #kity-minder, div.kmui-editor-body { html, body, #kityminder, div.kmui-editor-body {
height:100%; height: 100%;
width:100% width: 100%;
overflow: hidden;
-moz-user-select: none; -moz-user-select: none;
} }
.km_receiver{ .km_receiver{
......
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