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
89fa2d72
Commit
89fa2d72
authored
Feb 24, 2014
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拖动问题修复
parent
18bc4986
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
16 deletions
+12
-16
hand.js
src/module/hand.js
+12
-16
No files found.
src/module/hand.js
View file @
89fa2d72
...
...
@@ -21,18 +21,19 @@ var ViewDragger = kity.createClass( "ViewDragger", {
_bind
:
function
()
{
var
dragger
=
this
,
isRootDrag
=
false
,
star
tPosition
=
null
,
las
tPosition
=
null
;
las
tPosition
=
null
,
curren
tPosition
=
null
;
this
.
_minder
.
on
(
'beforemousedown'
,
function
(
e
)
{
// 已经被用户打开拖放模式
if
(
dragger
.
isEnabled
()
)
{
star
tPosition
=
e
.
getPosition
();
las
tPosition
=
e
.
getPosition
();
e
.
stopPropagation
();
}
// 点击未选中的根节点临时开启
else
if
(
!
this
.
getRoot
().
isSelected
()
&&
e
.
getTargetNode
()
==
this
.
getRoot
()
)
{
startPosition
=
e
.
getPosition
();
else
if
(
e
.
getTargetNode
()
==
this
.
getRoot
()
&&
(
!
this
.
getRoot
().
isSelected
()
||
!
this
.
isSingleSelect
()))
{
lastPosition
=
e
.
getPosition
();
dragger
.
setEnabled
(
true
);
isRootDrag
=
true
;
}
...
...
@@ -40,25 +41,20 @@ var ViewDragger = kity.createClass( "ViewDragger", {
}
)
.
on
(
'beforemousemove'
,
function
(
e
)
{
if
(
star
tPosition
)
{
las
tPosition
=
e
.
getPosition
();
if
(
las
tPosition
)
{
curren
tPosition
=
e
.
getPosition
();
// 当前偏移加上历史偏移
var
offset
=
kity
.
Vector
.
fromPoints
(
startPosition
,
lastPosition
);
offset
=
kity
.
Vector
.
add
(
dragger
.
_offset
,
offset
);
var
offset
=
kity
.
Vector
.
fromPoints
(
lastPosition
,
currentPosition
);
this
.
getRenderContainer
().
setTransform
(
new
kity
.
Matrix
().
translate
(
offset
.
x
,
offset
.
y
)
);
this
.
getRenderContainer
().
translate
(
offset
.
x
,
offset
.
y
);
e
.
stopPropagation
();
lastPosition
=
currentPosition
;
}
}
)
.
on
(
'mouseup'
,
function
(
e
)
{
if
(
startPosition
&&
lastPosition
)
{
// 合并更改的偏移到历史偏移
dragger
.
_offset
.
x
+=
lastPosition
.
x
-
startPosition
.
x
;
dragger
.
_offset
.
y
+=
lastPosition
.
y
-
startPosition
.
y
;
}
startPosition
=
null
;
lastPosition
=
null
;
// 临时拖动需要还原状态
if
(
isRootDrag
)
{
...
...
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