Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Frontend
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
matefun
Frontend
Commits
389c3609
Commit
389c3609
authored
6 years ago
by
Diego Rey
Browse files
Options
Downloads
Patches
Plain Diff
Fixed animation control for graph 2D
parent
a5ed5208
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts
+31
-9
31 additions, 9 deletions
...lar 4/src/app/layout/plotter/graph2D/graph2D.component.ts
with
31 additions
and
9 deletions
Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts
+
31
−
9
View file @
389c3609
...
...
@@ -29,6 +29,10 @@ export class Graph2DComponent {
public
constructor
(
private
ghciService
:
GHCIService
)
{
this
.
ghciServiceSub
=
ghciService
.
messages
.
subscribe
(
canvas
=>
{
// Stop Animation
if
(
this
.
animation
.
init
)
{
this
.
stopAnimation
();
}
switch
(
canvas
.
tipo
)
{
case
'
graph
'
:
{
var
jsonCanvas
=
JSON
.
parse
(
canvas
.
resultado
);
...
...
@@ -122,14 +126,12 @@ export class Graph2DComponent {
break
;
}
case
'
animacion
'
:
{
if
(
!
this
.
animation
.
init
)
{
this
.
animation
.
init
=
true
;
var
animationData
=
canvas
.
resultado
.
map
(
res
=>
JSON
.
parse
(
res
));
for
(
var
frame
of
animationData
)
{
this
.
animation
.
data
.
push
(
this
.
normalizeShapesData
(
frame
));
}
this
.
runAnimation
();
var
animationData
=
canvas
.
resultado
.
map
(
res
=>
JSON
.
parse
(
res
));
for
(
var
frame
of
animationData
)
{
this
.
animation
.
data
.
push
(
this
.
normalizeShapesData
(
frame
));
}
this
.
runAnimation
();
this
.
animation
.
init
=
true
;
break
;
}
}
...
...
@@ -199,6 +201,8 @@ export class Graph2DComponent {
]
})
}
// Update Frame
this
.
animation
.
currentFrame
=
(
this
.
animation
.
currentFrame
+
1
)
%
this
.
animation
.
data
.
length
;
}
/**
* @name runAnimation
...
...
@@ -207,9 +211,9 @@ export class Graph2DComponent {
public
runAnimation
=
function
()
{
var
$this
=
this
;
if
(
$this
.
animation
.
timer
!==
null
)
return
;
$this
.
updateFrame
(
$this
.
animation
.
data
[
$this
.
animation
.
currentFrame
]);
$this
.
animation
.
timer
=
setInterval
(
function
(){
$this
.
updateFrame
(
$this
.
animation
.
data
[
$this
.
animation
.
currentFrame
]);
$this
.
animation
.
currentFrame
=
(
$this
.
animation
.
currentFrame
+
1
)
%
$this
.
animation
.
data
.
length
;
},
$this
.
animation
.
speed
);
$this
.
animation
.
playing
=
true
;
}
...
...
@@ -223,6 +227,20 @@ export class Graph2DComponent {
$this
.
animation
.
timer
=
null
;
$this
.
animation
.
playing
=
false
;
}
/**
* @name stopAnimation
* @desc Stop Shapes Animation
*/
public
stopAnimation
=
function
()
{
var
$this
=
this
;
clearInterval
(
$this
.
animation
.
timer
);
$this
.
animation
.
data
=
[];
$this
.
animation
.
timer
=
null
;
$this
.
animation
.
currentFrame
=
0
;
$this
.
animation
.
speed
=
1000
;
$this
.
animation
.
playing
=
false
;
this
.
instance
.
removeAllGraphs
();
}
/**
* @name zoomOut
...
...
@@ -250,7 +268,11 @@ export class Graph2DComponent {
* @desc remove all the graph from the instance.
*/
public
cleanPlot
=
function
()
{
this
.
instance
.
removeAllGraphs
();
if
(
this
.
animation
.
playing
)
{
this
.
stopAnimation
();
}
else
{
this
.
instance
.
removeAllGraphs
();
}
}
/**
...
...
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