From d6b6a1d517d3ffa91271a1742bd5a844b5ec0ca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn?= <mmendez5163@gmail.com> Date: Fri, 3 Nov 2017 20:44:40 -0300 Subject: [PATCH] - Fix Focus luego de graficar algo en el canvas (grafica, figura o animacion) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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. --- .../src/app/layout/canvas/canvas.component.ts | 19 ++++++++++++++++--- .../src/app/shared/services/ghci.service.ts | 2 ++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Frontend Angular 4/src/app/layout/canvas/canvas.component.ts b/Frontend Angular 4/src/app/layout/canvas/canvas.component.ts index ab65632..9fdd2de 100644 --- a/Frontend Angular 4/src/app/layout/canvas/canvas.component.ts +++ b/Frontend Angular 4/src/app/layout/canvas/canvas.component.ts @@ -40,7 +40,7 @@ export class CanvasComponent { this.objetos = []; }) } - + animar_:boolean = true; objetos:any = []; evaluacionVertical:boolean = true; elementosAnimacion:any = []; @@ -161,6 +161,7 @@ export class CanvasComponent { } public limpiarCanvas = function(){ + this.animar_ = false; this.objetos = []; this.context.clearRect(0, 0, this.canvasRef.nativeElement.width, this.canvasRef.nativeElement.height); if(this.mostrarEjes || this.mostrarGrilla){ @@ -288,11 +289,21 @@ private generarExpresion = function(exp:any){ } private animar = function(){ + this.animar_ = true; if(this.mostrarEjes || this.mostrarGrilla){ this.drawXAxis(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.dibujarObjetos(); if(this.animando){ @@ -302,7 +313,9 @@ private animar = function(){ if(this.frameAnimacion>=this.elementosAnimacion.length){ this.frameAnimacion = 0; } - this.animar(); + if(this.animar_){ + this.animar(); + } } }.bind(this),1000); } diff --git a/Frontend Angular 4/src/app/shared/services/ghci.service.ts b/Frontend Angular 4/src/app/shared/services/ghci.service.ts index 8519b89..0682b5c 100644 --- a/Frontend Angular 4/src/app/shared/services/ghci.service.ts +++ b/Frontend Angular 4/src/app/shared/services/ghci.service.ts @@ -295,6 +295,8 @@ hayError(text){ this.startPrompt(); // console.log(x); }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); } -- GitLab