Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
matefun
Frontend
Commits
389c3609
Commit
389c3609
authored
Aug 19, 2018
by
Diego Rey
Browse files
Fixed animation control for graph 2D
parent
a5ed5208
Changes
1
Hide whitespace changes
Inline
Side-by-side
Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts
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
();
}
}
/**
...
...
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