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
9be1c436
Commit
9be1c436
authored
Jan 08, 2014
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
touch support
parent
7b0811c0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
7 deletions
+42
-7
minder.event.js
src/core/minder.event.js
+1
-1
mouse.js
src/module/mouse.js
+41
-6
No files found.
src/core/minder.event.js
View file @
9be1c436
...
@@ -14,7 +14,7 @@ kity.extendClass( Minder, {
...
@@ -14,7 +14,7 @@ kity.extendClass( Minder, {
// TODO: mousemove lazy bind
// TODO: mousemove lazy bind
_bindPaperEvents
:
function
()
{
_bindPaperEvents
:
function
()
{
var
minder
=
this
;
var
minder
=
this
;
this
.
_paper
.
on
(
'click mousedown mouseup mousemove'
,
this
.
_firePharse
.
bind
(
this
)
);
this
.
_paper
.
on
(
'click mousedown mouseup mousemove
touchstart touchmove touchend
'
,
this
.
_firePharse
.
bind
(
this
)
);
},
},
_bindKeyboardEvents
:
function
()
{
_bindKeyboardEvents
:
function
()
{
var
minder
=
this
;
var
minder
=
this
;
...
...
src/module/mouse.js
View file @
9be1c436
...
@@ -45,6 +45,8 @@ KityMinder.registerModule( "MouseModule", function () {
...
@@ -45,6 +45,8 @@ KityMinder.registerModule( "MouseModule", function () {
paper
.
off
(
DRAG_MOVE_EVENT
,
dragFn
);
paper
.
off
(
DRAG_MOVE_EVENT
,
dragFn
);
}
}
if
(
e
.
originEvent
.
touches
&&
e
.
originEvent
.
touches
.
length
!==
1
)
return
;
var
currentPosition
=
e
.
getPosition
();
var
currentPosition
=
e
.
getPosition
();
var
movement
=
{
var
movement
=
{
x
:
currentPosition
.
x
-
startPosition
.
x
,
x
:
currentPosition
.
x
-
startPosition
.
x
,
...
@@ -106,15 +108,12 @@ KityMinder.registerModule( "MouseModule", function () {
...
@@ -106,15 +108,12 @@ KityMinder.registerModule( "MouseModule", function () {
paper
.
on
(
DRAG_END_EVENT
,
dragTarget
.
_dragEndHandler
=
function
(
e
)
{
paper
.
on
(
DRAG_END_EVENT
,
dragTarget
.
_dragEndHandler
=
function
(
e
)
{
if
(
dragging
)
{
if
(
dragging
)
{
dragging
=
false
;
dragging
=
false
;
var
dragInfo
=
{
position
:
e
.
getPosition
()
};
if
(
dragEnd
)
{
if
(
dragEnd
)
{
dragEnd
.
call
(
me
,
dragInfo
);
dragEnd
.
call
(
me
);
}
}
paper
.
off
(
DRAG_MOVE_EVENT
,
dragFn
);
paper
.
off
(
DRAG_MOVE_EVENT
,
dragFn
);
dragTarget
.
trigger
(
'dragend'
,
dragInfo
);
dragTarget
.
trigger
(
'dragend'
);
e
.
stopPropagation
();
e
.
stopPropagation
();
e
.
preventDefault
();
e
.
preventDefault
();
...
@@ -151,6 +150,10 @@ KityMinder.registerModule( "MouseModule", function () {
...
@@ -151,6 +150,10 @@ KityMinder.registerModule( "MouseModule", function () {
}
}
}
);
}
);
}
)();
}
)();
function
getTouchDistance
(
e
)
{
return
kity
.
Vector
.
fromPoints
(
e
.
kityEvent
.
getPosition
(
0
),
e
.
kityEvent
.
getPosition
(
1
)
).
length
();
}
return
{
return
{
"init"
:
function
()
{
"init"
:
function
()
{
kity
.
extendClass
(
kity
.
Paper
,
Draggable
);
kity
.
extendClass
(
kity
.
Paper
,
Draggable
);
...
@@ -160,7 +163,9 @@ KityMinder.registerModule( "MouseModule", function () {
...
@@ -160,7 +163,9 @@ KityMinder.registerModule( "MouseModule", function () {
'selectsingle'
:
SingleSelectCommand
'selectsingle'
:
SingleSelectCommand
},
},
"events"
:
{
"events"
:
{
mousedown
:
function
(
e
)
{
'mousedown touchstart'
:
function
(
e
)
{
if
(
e
.
originEvent
.
touches
&&
e
.
originEvent
.
touches
.
length
!=
1
)
return
;
var
clickNode
=
e
.
getTargetNode
();
var
clickNode
=
e
.
getTargetNode
();
this
.
execCommand
(
'selectsingle'
,
clickNode
);
this
.
execCommand
(
'selectsingle'
,
clickNode
);
if
(
+
new
Date
()
-
this
.
_lastMousedownTime
<
300
)
{
if
(
+
new
Date
()
-
this
.
_lastMousedownTime
<
300
)
{
...
@@ -169,6 +174,36 @@ KityMinder.registerModule( "MouseModule", function () {
...
@@ -169,6 +174,36 @@ KityMinder.registerModule( "MouseModule", function () {
}
}
}
}
this
.
_lastMousedownTime
=
+
new
Date
();
this
.
_lastMousedownTime
=
+
new
Date
();
},
'touchstart'
:
function
(
e
)
{
var
me
=
this
;
if
(
e
.
originEvent
.
touches
.
length
===
2
)
{
this
.
_lastTouchDistance
=
getTouchDistance
(
e
);
this
.
_lastTouchViewport
=
this
.
_paper
.
getViewPort
();
console
.
log
(
'start: '
,
this
.
_lastTouchDistance
,
this
.
_lastTouchViewport
);
}
else
if
(
e
.
originEvent
.
touches
.
length
===
1
)
{
var
node
=
e
.
getTargetNode
();
if
(
!
node
)
return
;
this
.
_touchTimeout
=
setTimeout
(
function
()
{
me
.
clearSelect
();
me
.
execCommand
(
'kbCreateAndEdit'
,
'child'
,
node
);
},
200
);
}
},
'touchend touchmove'
:
function
()
{
clearTimeout
(
this
.
_touchTimeout
);
},
'touchmove'
:
function
(
e
)
{
if
(
e
.
originEvent
.
touches
.
length
===
2
)
{
var
ld
=
this
.
_lastTouchDistance
,
cd
=
getTouchDistance
(
e
);
var
lv
=
this
.
_lastTouchViewport
,
cv
=
this
.
_paper
.
getViewPort
();
cv
.
zoom
=
lv
.
zoom
*
cd
/
ld
;
this
.
_paper
.
setViewPort
(
cv
);
console
.
log
(
'move: '
,
cv
);
}
}
}
}
}
};
};
...
...
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