Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kityminder-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
吴志俊
kityminder-core
Commits
17d20b9c
Commit
17d20b9c
authored
Feb 22, 2014
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dragview on root
parent
e02893e6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
156 deletions
+61
-156
kity
kity
+1
-1
dragtree.js
src/module/dragtree.js
+1
-1
hand.js
src/module/hand.js
+57
-153
layout.js
src/module/layout.js
+2
-1
No files found.
kity
@
a9630e63
Subproject commit
df7b361ae5098710eca0fec1080dce4bc822bf24
Subproject commit
a9630e638b29633f62cdc2df239bc702118b231a
src/module/dragtree.js
View file @
17d20b9c
...
@@ -161,7 +161,7 @@ var DragBox = kity.createClass( "DragBox", {
...
@@ -161,7 +161,7 @@ var DragBox = kity.createClass( "DragBox", {
_drawForDragMode
:
function
()
{
_drawForDragMode
:
function
()
{
this
.
_text
.
setContent
(
this
.
_dragSources
.
length
+
' items'
);
this
.
_text
.
setContent
(
this
.
_dragSources
.
length
+
' items'
);
this
.
_text
.
setPosition
(
this
.
_startPosition
.
x
,
this
.
_startPosition
.
y
+
5
);
this
.
_text
.
setPosition
(
this
.
_startPosition
.
x
,
this
.
_startPosition
.
y
+
5
);
this
.
_minder
.
get
RenderContain
er
().
addShape
(
this
);
this
.
_minder
.
get
Pap
er
().
addShape
(
this
);
},
},
_shrink
:
function
()
{
_shrink
:
function
()
{
// 合并所有拖放源图形的矩形即可
// 合并所有拖放源图形的矩形即可
...
...
src/module/hand.js
View file @
17d20b9c
kity
.
Draggable
=
(
function
()
{
var
ViewDragger
=
kity
.
createClass
(
"ViewDragger"
,
{
var
Paper
=
kity
.
Paper
;
constructor
:
function
(
minder
)
{
this
.
_minder
=
minder
;
var
touchable
=
window
.
ontouchstart
!==
undefined
;
this
.
_enabled
=
false
;
var
DRAG_START_EVENT
=
touchable
?
'touchstart'
:
'mousedown'
,
this
.
_offset
=
{
DRAG_MOVE_EVENT
=
touchable
?
'touchmove'
:
'mousemove'
,
x
:
0
,
DRAG_END_EVENT
=
touchable
?
'touchend'
:
'mouseup'
;
y
:
0
};
return
kity
.
createClass
(
{
this
.
_bind
();
drag
:
function
(
opt
)
{
},
isEnabled
:
function
()
{
if
(
this
.
dragEnabled
)
{
return
this
.
_enabled
;
return
;
},
setEnabled
:
function
(
value
)
{
var
paper
=
this
.
_minder
.
getPaper
();
paper
.
setStyle
(
'cursor'
,
value
?
'pointer'
:
'default'
);
paper
.
setStyle
(
'cursor'
,
value
?
'-webkit-grab'
:
'default'
);
this
.
_enabled
=
value
;
},
_bind
:
function
()
{
var
dragger
=
this
,
isRootDrag
=
false
,
startPosition
=
null
,
lastPosition
=
null
;
this
.
_minder
.
on
(
'beforemousedown'
,
function
(
e
)
{
if
(
dragger
.
isEnabled
()
)
{
startPosition
=
e
.
getPosition
();
e
.
stopPropagation
();
}
else
if
(
!
this
.
getRoot
().
isSelected
()
&&
e
.
getTargetNode
()
==
this
.
getRoot
()
)
{
startPosition
=
e
.
getPosition
();
dragger
.
setEnabled
(
true
);
isRootDrag
=
true
;
}
}
var
dragStart
=
opt
&&
opt
.
start
||
this
.
dragStart
,
}
).
on
(
'beforemousemove'
,
function
(
e
)
{
dragMove
=
opt
&&
opt
.
move
||
this
.
dragMove
,
if
(
startPosition
)
{
dragEnd
=
opt
&&
opt
.
end
||
this
.
dragEnd
,
lastPosition
=
e
.
getPosition
();
dragTarget
=
opt
&&
opt
.
target
||
this
.
dragTarget
||
this
,
var
offset
=
kity
.
Vector
.
fromPoints
(
startPosition
,
lastPosition
);
me
=
this
;
offset
=
kity
.
Vector
.
add
(
dragger
.
_offset
,
offset
);
this
.
getRenderContainer
().
setTransform
(
new
kity
.
Matrix
().
translate
(
offset
.
x
,
offset
.
y
)
);
this
.
dragEnabled
=
true
;
e
.
stopPropagation
();
this
.
dragTarget
=
dragTarget
;
function
bindEvents
(
paper
)
{
var
startPosition
,
lastPosition
,
dragging
=
false
;
var
dragFn
=
function
(
e
)
{
if
(
!
dragging
)
{
paper
.
off
(
DRAG_MOVE_EVENT
,
dragFn
);
}
if
(
e
.
originEvent
.
touches
&&
e
.
originEvent
.
touches
.
length
!==
1
)
return
;
var
currentPosition
=
e
.
getPosition
();
var
movement
=
{
x
:
currentPosition
.
x
-
startPosition
.
x
,
y
:
currentPosition
.
y
-
startPosition
.
y
};
var
delta
=
{
x
:
currentPosition
.
x
-
lastPosition
.
x
,
y
:
currentPosition
.
y
-
lastPosition
.
y
};
var
dragInfo
=
{
position
:
currentPosition
,
movement
:
movement
,
delta
:
delta
};
lastPosition
=
currentPosition
;
if
(
dragMove
)
{
dragMove
.
call
(
me
,
dragInfo
);
}
else
if
(
me
instanceof
Paper
)
{
// treate paper drag different
var
view
=
me
.
getViewPort
();
view
.
center
.
x
-=
movement
.
x
;
view
.
center
.
y
-=
movement
.
y
;
me
.
setViewPort
(
view
);
}
else
{
me
.
translate
(
delta
.
x
,
delta
.
y
);
}
dragTarget
.
trigger
(
'dragmove'
,
dragInfo
);
e
.
stopPropagation
();
e
.
preventDefault
();
};
dragTarget
.
on
(
DRAG_START_EVENT
,
dragTarget
.
_dragStartHandler
=
function
(
e
)
{
if
(
e
.
originEvent
.
button
)
{
return
;
}
dragging
=
true
;
var
dragInfo
=
{
position
:
lastPosition
=
startPosition
=
e
.
getPosition
()
};
if
(
dragStart
)
{
var
cancel
=
dragStart
.
call
(
me
,
dragInfo
)
===
false
;
if
(
cancel
)
{
return
;
}
}
paper
.
on
(
DRAG_MOVE_EVENT
,
dragFn
);
dragTarget
.
trigger
(
'dragstart'
,
dragInfo
);
e
.
stopPropagation
();
e
.
preventDefault
();
}
);
paper
.
on
(
DRAG_END_EVENT
,
dragTarget
.
_dragEndHandler
=
function
(
e
)
{
if
(
dragging
)
{
dragging
=
false
;
if
(
dragEnd
)
{
dragEnd
.
call
(
me
);
}
paper
.
off
(
DRAG_MOVE_EVENT
,
dragFn
);
dragTarget
.
trigger
(
'dragend'
);
if
(
e
)
{
e
.
stopPropagation
();
e
.
preventDefault
();
}
}
}
);
}
}
}
).
on
(
'mouseup'
,
function
(
e
)
{
if
(
me
instanceof
Paper
)
{
if
(
startPosition
&&
lastPosition
)
{
bindEvents
(
me
);
dragger
.
_offset
.
x
+=
lastPosition
.
x
-
startPosition
.
x
;
}
else
if
(
me
.
getPaper
()
)
{
dragger
.
_offset
.
y
+=
lastPosition
.
y
-
startPosition
.
y
;
bindEvents
(
me
.
getPaper
()
);
}
else
{
var
listener
=
function
(
e
)
{
if
(
e
.
targetShape
.
getPaper
()
)
{
bindEvents
(
e
.
targetShape
.
getPaper
()
);
me
.
off
(
'add'
,
listener
);
me
.
off
(
'treeadd'
,
listener
);
}
};
me
.
on
(
'add treeadd'
,
listener
);
}
}
return
this
;
startPosition
=
null
;
},
// end of drag
if
(
isRootDrag
)
{
dragger
.
setEnabled
(
false
);
isRootDrag
=
false
;
undrag
:
function
()
{
}
var
target
=
this
.
dragTarget
;
}
);
target
.
off
(
DRAG_START_EVENT
,
target
.
_dragStartHandler
);
}
target
.
_dragEndHandler
();
}
);
target
.
getPaper
().
off
(
DRAG_END_EVENT
,
target
.
_dragEndHandler
);
delete
target
.
_dragStartHandler
;
delete
target
.
_dragEndHandler
;
this
.
dragEnabled
=
false
;
return
this
;
}
}
);
}
)();
KityMinder
.
registerModule
(
'Hand'
,
function
()
{
KityMinder
.
registerModule
(
'Hand'
,
function
()
{
var
ToggleHandCommand
=
kity
.
createClass
(
"ToggleHandCommand"
,
{
var
ToggleHandCommand
=
kity
.
createClass
(
"ToggleHandCommand"
,
{
base
:
Command
,
base
:
Command
,
execute
:
function
(
minder
)
{
execute
:
function
(
minder
)
{
var
drag
=
minder
.
_onDragMode
=
!
minder
.
_onDragMode
;
minder
.
_viewDragger
.
setEnabled
(
!
minder
.
_viewDragger
.
isEnabled
()
);
minder
.
getPaper
().
setStyle
(
'cursor'
,
drag
?
'pointer'
:
'default'
);
minder
.
getPaper
().
setStyle
(
'cursor'
,
drag
?
'-webkit-grab'
:
'default'
);
if
(
drag
)
{
minder
.
getPaper
().
drag
();
}
else
{
minder
.
getPaper
().
undrag
();
}
},
},
queryState
:
function
(
minder
)
{
queryState
:
function
(
minder
)
{
return
minder
.
_
onDragMode
?
1
:
0
;
return
minder
.
_
viewDragger
.
isEnabled
()
?
1
:
0
;
}
}
}
);
}
);
return
{
return
{
init
:
function
()
{
init
:
function
()
{
this
.
_onDragMode
=
false
;
this
.
_viewDragger
=
new
ViewDragger
(
this
);
kity
.
extendClass
(
kity
.
Paper
,
kity
.
Draggable
);
},
},
commands
:
{
commands
:
{
'hand'
:
ToggleHandCommand
'hand'
:
ToggleHandCommand
...
@@ -172,11 +81,6 @@ KityMinder.registerModule( 'Hand', function () {
...
@@ -172,11 +81,6 @@ KityMinder.registerModule( 'Hand', function () {
this
.
execCommand
(
'hand'
);
this
.
execCommand
(
'hand'
);
e
.
preventDefault
();
e
.
preventDefault
();
}
}
},
beforemousemove
:
function
(
e
)
{
if
(
this
.
_onDragMode
)
{
e
.
stopPropagation
();
}
}
}
}
}
};
};
...
...
src/module/layout.js
View file @
17d20b9c
...
@@ -29,8 +29,9 @@ KityMinder.registerModule( "LayoutModule", function () {
...
@@ -29,8 +29,9 @@ KityMinder.registerModule( "LayoutModule", function () {
},
},
initStyle
:
function
()
{
initStyle
:
function
()
{
var
curStyle
=
this
.
getCurrentStyle
();
var
curStyle
=
this
.
getCurrentStyle
();
var
lastTransform
=
this
.
_rc
.
getTransform
();
this
.
_rc
.
remove
();
this
.
_rc
.
remove
();
this
.
_rc
=
new
kity
.
Group
();
this
.
_rc
=
new
kity
.
Group
()
.
setTransform
(
lastTransform
)
;
this
.
_paper
.
addShape
(
this
.
_rc
);
this
.
_paper
.
addShape
(
this
.
_rc
);
var
_root
=
this
.
getRoot
();
var
_root
=
this
.
getRoot
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment