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
890bdcdc
Commit
890bdcdc
authored
Jul 07, 2014
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加右键拖动的功能
parent
4d023087
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
13 deletions
+19
-13
contextmenu.js
src/adapter/contextmenu.js
+6
-3
view.js
src/module/view.js
+13
-10
No files found.
src/adapter/contextmenu.js
View file @
890bdcdc
...
@@ -27,7 +27,11 @@ KM.registerUI( 'contextmenu', function () {
...
@@ -27,7 +27,11 @@ KM.registerUI( 'contextmenu', function () {
}
}
});
});
me
.
$container
.
append
(
$menu
);
me
.
$container
.
append
(
$menu
);
me
.
on
(
'contextmenu'
,
function
(
e
){
me
.
on
(
'contextmenu'
,
function
(
e
)
{
e
.
preventDefault
();
if
(
me
.
getStatus
()
==
'hand'
)
return
;
var
node
=
e
.
getTargetNode
();
var
node
=
e
.
getTargetNode
();
if
(
node
){
if
(
node
){
this
.
removeAllSelectedNodes
();
this
.
removeAllSelectedNodes
();
...
@@ -59,7 +63,6 @@ KM.registerUI( 'contextmenu', function () {
...
@@ -59,7 +63,6 @@ KM.registerUI( 'contextmenu', function () {
data
:
data
data
:
data
}).
position
(
e
.
getPosition
()).
show
();
}).
position
(
e
.
getPosition
()).
show
();
}
}
e
.
preventDefault
()
});
});
me
.
on
(
'click'
,
function
(){
me
.
on
(
'click'
,
function
(){
...
@@ -67,7 +70,7 @@ KM.registerUI( 'contextmenu', function () {
...
@@ -67,7 +70,7 @@ KM.registerUI( 'contextmenu', function () {
});
});
me
.
on
(
'beforemousedown'
,
function
(
e
){
me
.
on
(
'beforemousedown'
,
function
(
e
){
if
(
e
.
isRightMB
()){
if
(
e
.
isRightMB
()){
e
.
stopPropagationImmediately
();
//
e.stopPropagationImmediately();
}
}
})
})
}
);
}
);
...
...
src/module/view.js
View file @
890bdcdc
...
@@ -24,20 +24,21 @@ var ViewDragger = kity.createClass("ViewDragger", {
...
@@ -24,20 +24,21 @@ var ViewDragger = kity.createClass("ViewDragger", {
_bind
:
function
()
{
_bind
:
function
()
{
var
dragger
=
this
,
var
dragger
=
this
,
is
Root
Drag
=
false
,
is
Temp
Drag
=
false
,
lastPosition
=
null
,
lastPosition
=
null
,
currentPosition
=
null
;
currentPosition
=
null
;
this
.
_minder
.
on
(
'normal.mousedown readonly.mousedown readonly.touchstart'
,
function
(
e
)
{
this
.
_minder
.
on
(
'normal.beforemousedown readonly.mousedown readonly.touchstart'
,
function
(
e
)
{
e
.
originEvent
.
preventDefault
();
// 阻止中键拉动
// 点击未选中的根节点临时开启
// 点击未选中的根节点临时开启
if
(
e
.
getTargetNode
()
==
this
.
getRoot
())
{
if
(
e
.
getTargetNode
()
==
this
.
getRoot
()
||
e
.
originEvent
.
button
==
2
)
{
lastPosition
=
e
.
getPosition
();
lastPosition
=
e
.
getPosition
();
is
Root
Drag
=
true
;
is
Temp
Drag
=
true
;
}
}
})
})
.
on
(
'normal.mousemove normal.touchmove'
,
function
(
e
)
{
.
on
(
'normal.mousemove normal.touchmove'
,
function
(
e
)
{
if
(
!
is
Root
Drag
)
return
;
if
(
!
is
Temp
Drag
)
return
;
var
offset
=
kity
.
Vector
.
fromPoints
(
lastPosition
,
e
.
getPosition
());
var
offset
=
kity
.
Vector
.
fromPoints
(
lastPosition
,
e
.
getPosition
());
if
(
offset
.
length
()
>
3
)
this
.
setStatus
(
'hand'
);
if
(
offset
.
length
()
>
3
)
this
.
setStatus
(
'hand'
);
})
})
...
@@ -68,10 +69,13 @@ var ViewDragger = kity.createClass("ViewDragger", {
...
@@ -68,10 +69,13 @@ var ViewDragger = kity.createClass("ViewDragger", {
lastPosition
=
null
;
lastPosition
=
null
;
// 临时拖动需要还原状态
// 临时拖动需要还原状态
if
(
is
Root
Drag
)
{
if
(
is
Temp
Drag
)
{
dragger
.
setEnabled
(
false
);
dragger
.
setEnabled
(
false
);
isRootDrag
=
false
;
isTempDrag
=
false
;
this
.
rollbackStatus
();
var
me
=
this
;
setTimeout
(
function
()
{
me
.
rollbackStatus
();
});
}
}
});
});
}
}
...
@@ -155,11 +159,10 @@ KityMinder.registerModule('View', function() {
...
@@ -155,11 +159,10 @@ KityMinder.registerModule('View', function() {
e
.
preventDefault
();
e
.
preventDefault
();
}
}
},
},
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
)
{
dx
=
e
.
wheelDeltaX
||
0
;
dx
=
e
.
wheelDeltaX
||
0
;
...
...
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