Skip to content
Snippets Groups Projects
Commit d6b6a1d5 authored by Martín's avatar Martín
Browse files

- Fix Focus luego de graficar algo en el canvas (grafica, figura o animacion)

- Fix. Luego de una animación, si se graficaba algo, cuando se ejecutaba el callback del setimeout, borraba el gráfico y la animación continuaba. Quedó solucionado.
parent 8a840bfa
No related branches found
No related tags found
No related merge requests found
...@@ -40,7 +40,7 @@ export class CanvasComponent { ...@@ -40,7 +40,7 @@ export class CanvasComponent {
this.objetos = []; this.objetos = [];
}) })
} }
animar_:boolean = true;
objetos:any = []; objetos:any = [];
evaluacionVertical:boolean = true; evaluacionVertical:boolean = true;
elementosAnimacion:any = []; elementosAnimacion:any = [];
...@@ -161,6 +161,7 @@ export class CanvasComponent { ...@@ -161,6 +161,7 @@ export class CanvasComponent {
} }
public limpiarCanvas = function(){ public limpiarCanvas = function(){
this.animar_ = false;
this.objetos = []; this.objetos = [];
this.context.clearRect(0, 0, this.canvasRef.nativeElement.width, this.canvasRef.nativeElement.height); this.context.clearRect(0, 0, this.canvasRef.nativeElement.width, this.canvasRef.nativeElement.height);
if(this.mostrarEjes || this.mostrarGrilla){ if(this.mostrarEjes || this.mostrarGrilla){
...@@ -288,11 +289,21 @@ private generarExpresion = function(exp:any){ ...@@ -288,11 +289,21 @@ private generarExpresion = function(exp:any){
} }
private animar = function(){ private animar = function(){
this.animar_ = true;
if(this.mostrarEjes || this.mostrarGrilla){ if(this.mostrarEjes || this.mostrarGrilla){
this.drawXAxis(this.context); this.drawXAxis(this.context);
this.drawYAxis(this.context); this.drawYAxis(this.context);
} }
this.limpiarCanvas(); //limpio canvas.
this.objetos = [];
this.context.clearRect(0, 0, this.canvasRef.nativeElement.width, this.canvasRef.nativeElement.height);
if(this.mostrarEjes || this.mostrarGrilla){
this.drawXAxis(this.context);
this.drawYAxis(this.context);
}
this.objetos = this.elementosAnimacion[this.frameAnimacion]; this.objetos = this.elementosAnimacion[this.frameAnimacion];
this.dibujarObjetos(); this.dibujarObjetos();
if(this.animando){ if(this.animando){
...@@ -302,7 +313,9 @@ private animar = function(){ ...@@ -302,7 +313,9 @@ private animar = function(){
if(this.frameAnimacion>=this.elementosAnimacion.length){ if(this.frameAnimacion>=this.elementosAnimacion.length){
this.frameAnimacion = 0; this.frameAnimacion = 0;
} }
this.animar(); if(this.animar_){
this.animar();
}
} }
}.bind(this),1000); }.bind(this),1000);
} }
......
...@@ -295,6 +295,8 @@ hayError(text){ ...@@ -295,6 +295,8 @@ hayError(text){
this.startPrompt(); this.startPrompt();
// console.log(x); // console.log(x);
}else if (json_server_message.tipo == 'canvas' || json_server_message.tipo == 'animacion' || json_server_message.tipo == 'graph'){ }else if (json_server_message.tipo == 'canvas' || json_server_message.tipo == 'animacion' || json_server_message.tipo == 'graph'){
document.getElementById("FigurasBtn").click()
this.focusConsole();
this.messages.next(json_server_message); this.messages.next(json_server_message);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment