Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Knowledge Space WP Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alg
Knowledge Space WP Plugin
Commits
210916cd
Commit
210916cd
authored
3 years ago
by
Maximilian Giller
Browse files
Options
Downloads
Patches
Plain Diff
Implemented drag to click handling into tool and state
parent
c7596c35
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#52704
passed
3 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
editor/js/editor.js
+2
-11
2 additions, 11 deletions
editor/js/editor.js
editor/js/state.js
+13
-0
13 additions, 0 deletions
editor/js/state.js
editor/js/tools/tool.js
+6
-0
6 additions, 0 deletions
editor/js/tools/tool.js
with
21 additions
and
11 deletions
editor/js/editor.js
+
2
−
11
View file @
210916cd
...
...
@@ -3,7 +3,7 @@ import * as Graph from "./graph";
import
{
loadGraphJson
}
from
"
../../datasets/datasets
"
;
import
ForceGraph
from
"
force-graph
"
;
import
*
as
Interactions
from
"
./interactions
"
;
import
{
DRAG_THRESHOLD_2D
,
setSpace
,
SPACE
}
from
"
../../config
"
;
import
{
setSpace
,
SPACE
}
from
"
../../config
"
;
export
var
state
=
undefined
;
export
var
graph
=
undefined
;
...
...
@@ -57,7 +57,7 @@ function load() {
.
linkColor
((
link
)
=>
state
.
linkColor
(
link
))
.
nodeColor
((
node
)
=>
state
.
nodeColor
(
node
))
.
onNodeClick
((
node
)
=>
state
.
onNodeClick
(
node
))
.
onNodeDragEnd
((
node
,
translate
)
=>
onNodeDragEnd
(
node
,
translate
))
.
onNodeDragEnd
((
node
,
translate
)
=>
state
.
onNodeDragEnd
(
node
,
translate
))
.
autoPauseRedraw
(
false
)
// keep redrawing after engine has stopped
.
linkWidth
((
link
)
=>
state
.
linkWidth
(
link
))
.
linkDirectionalParticles
(
state
.
linkDirectionalParticles
())
...
...
@@ -81,12 +81,3 @@ function load() {
graphObj
.
graphData
(
data
);
});
}
function
onNodeDragEnd
(
node
,
translate
)
{
if
(
Math
.
sqrt
(
Math
.
pow
(
translate
.
x
,
2
)
+
Math
.
pow
(
translate
.
y
,
2
))
<
DRAG_THRESHOLD_2D
)
{
state
.
onNodeClick
(
node
);
}
}
This diff is collapsed.
Click to expand it.
editor/js/state.js
+
13
−
0
View file @
210916cd
...
...
@@ -10,6 +10,7 @@ import SaveTool from "./tools/savetool";
import
{
graph
}
from
"
./editor
"
;
import
Toolbar
from
"
./toolbar
"
;
import
*
as
Graph
from
"
./graph
"
;
import
{
DRAG_THRESHOLD_2D
}
from
"
../../config
"
;
export
const
TOOLS
=
{
undo
:
new
UndoTool
(
"
undo
"
),
...
...
@@ -86,6 +87,18 @@ export class State extends Tool {
this
.
tool
.
onNodeClick
(
node
);
}
onNodeDragEnd
(
node
,
translate
)
{
// Handle as click event, if drag distance under a certain threshold
var
distanceDragged
=
Math
.
sqrt
(
Math
.
pow
(
translate
.
x
,
2
)
+
Math
.
pow
(
translate
.
y
,
2
));
if
(
distanceDragged
<
DRAG_THRESHOLD_2D
)
{
this
.
onNodeClick
(
node
);
return
;
}
else
{
this
.
tool
.
onNodeDragEnd
(
node
,
translate
);
}
}
onLinkClick
(
link
)
{
this
.
tool
.
onLinkClick
(
link
);
}
...
...
This diff is collapsed.
Click to expand it.
editor/js/tools/tool.js
+
6
−
0
View file @
210916cd
...
...
@@ -64,6 +64,12 @@ export default class Tool {
}
}
onNodeDragEnd
(
node
,
translate
)
{
if
(
this
.
warnings
)
{
console
.
warn
(
'
Method "onNodeDragEnd" not implemented.
'
);
}
}
onLinkClick
(
link
)
{
if
(
this
.
warnings
)
{
console
.
warn
(
'
Method "onLinkClick" not implemented.
'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment