Comparing version 0.8.2 to 0.8.3
{ | ||
"name": "infrontjs", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"description": "The frontend framework.", | ||
@@ -5,0 +5,0 @@ "main": "src/IF.js", |
@@ -83,6 +83,34 @@ import { State } from "./State.js"; | ||
this.bufObj = {}; | ||
this.mousepos = [0,0]; | ||
this.initScene(); | ||
} | ||
async exit() | ||
{ | ||
this.destroyScene(); | ||
this.app.container.innerHTML = ''; | ||
} | ||
destroyScene() | ||
{ | ||
if ( this.RAF_ID ) | ||
{ | ||
cancelAnimationFrame( this.RAF_ID ); | ||
} | ||
if ( !this.gl ) | ||
{ | ||
return; | ||
} | ||
if ( this.FRAG_ID ) | ||
{ | ||
this.gl.deleteShader( this.FRAG_ID ); | ||
} | ||
if ( this.VERTEX_ID ) | ||
{ | ||
this.gl.deleteShader( this.VERTEX_ID ); | ||
} | ||
} | ||
initScene() | ||
@@ -95,7 +123,2 @@ { | ||
this.canvas.addEventListener( 'mousemove', ( e ) => | ||
{ | ||
this.mousepos = [ e.clientX, e.clientY ]; | ||
} ); | ||
this.progDraw = this.gl.createProgram(); | ||
@@ -106,2 +129,10 @@ for ( let i = 0; i < 2; ++i ) | ||
let shaderObj = this.gl.createShader( i == 0 ? this.gl.VERTEX_SHADER : this.gl.FRAGMENT_SHADER ); | ||
if ( i === 0 ) | ||
{ | ||
this.VERTEX_ID = shaderObj; | ||
} | ||
else | ||
{ | ||
this.FRAG_ID = shaderObj; | ||
} | ||
this.gl.shaderSource( shaderObj, source ); | ||
@@ -140,3 +171,3 @@ this.gl.compileShader( shaderObj ); | ||
this.resize(); | ||
requestAnimationFrame( this.render.bind( this ) ); | ||
this.RAF_ID = requestAnimationFrame( this.render.bind( this ) ); | ||
} | ||
@@ -161,6 +192,5 @@ | ||
this.gl.uniform2f(this.progDraw.iResolution, this.canvas.width, this.canvas.height); | ||
this.gl.uniform2f(this.progDraw.iMouse, this.mousepos[0], this.mousepos[1]); | ||
this.gl.drawElements( this.gl.TRIANGLES, this.bufObj.inx.len, this.gl.UNSIGNED_SHORT, 0 ); | ||
requestAnimationFrame(this.render.bind( this )); | ||
this.RAF_ID = requestAnimationFrame(this.render.bind( this )); | ||
} | ||
@@ -167,0 +197,0 @@ |
@@ -11,3 +11,3 @@ import { Router } from "./Router.js"; | ||
const VERSION = '0.8.2'; | ||
const VERSION = '0.8.3'; | ||
@@ -79,5 +79,8 @@ const DEFAULT_PROPS = { | ||
this.container = document.querySelector( this.container ); | ||
if ( false === this.container instanceof HTMLElement ) | ||
{ | ||
throw new Error( 'Invalid app container.' ); | ||
} | ||
} | ||
if ( !this.container || false === this.container instanceof HTMLElement ) | ||
else | ||
{ | ||
@@ -84,0 +87,0 @@ this.container = document.querySelector( 'body' ); |
@@ -90,2 +90,3 @@ import { RouteParams } from "./RouteParams.js"; | ||
// 404 | ||
console.error( 404 ); | ||
} | ||
@@ -135,2 +136,10 @@ | ||
this.isEnabled = false; | ||
if ( this.mode === 'url' ) | ||
{ | ||
document.removeEventListener( 'click', this.processUrl.bind( this ) ); | ||
} | ||
else if ( this.mode = 'hash' ) | ||
{ | ||
window.removeEventListener( 'hashchange', this.processHash.bind( this ) ); | ||
} | ||
} | ||
@@ -148,3 +157,2 @@ | ||
this.currentRoute = route; | ||
console.log( route ); | ||
this.execute( this.resolveActionDataByRoute( route ) ); | ||
@@ -183,4 +191,2 @@ } | ||
console.log( route ); | ||
const actionData = this.resolveActionDataByRoute( route ); | ||
@@ -187,0 +193,0 @@ if ( actionData ) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
373527
9529