@@ -30,6 +30,7 @@ define(["iter2d", "csshelper", "evileval", "net", "ui"], function(iter2d, csshel
30
30
31
31
var makeCanvasAnimation = function ( context ) {
32
32
return {
33
+ updateListener :null ,
33
34
currentCode : null ,
34
35
context : context , //might be useful to debug
35
36
borders : function ( ) {
@@ -81,6 +82,7 @@ define(["iter2d", "csshelper", "evileval", "net", "ui"], function(iter2d, csshel
81
82
} ,
82
83
83
84
getSourceCodeString : function ( ) {
85
+ //TODO continue refactoring here, see doc.org
84
86
if ( this . uri . match ( / ^ d a t a : / ) ) {
85
87
// the code is in the cache
86
88
return new Promise ( function ( resolve , reject ) {
@@ -157,9 +159,19 @@ define(["iter2d", "csshelper", "evileval", "net", "ui"], function(iter2d, csshel
157
159
var names = fileUris . map ( store . uriToAnimationName ) ;
158
160
return ui . populateNamePicker ( "choose animation" , names ) ;
159
161
} ) . then ( function ( animationName ) {
160
- var fileUri = store . animationNameToUri ( animationName ) ;
161
- evileval . loadJsAnimOnCanvasAnim ( fileUri , canvasAnim , animationName ) ;
162
- //TODO notify or update the editor to fix the BUG
162
+ if ( animationName ) {
163
+ var fileUri = store . animationNameToUri ( animationName ) ;
164
+ return evileval . loadJsAnimOnCanvasAnim ( fileUri , canvasAnim , animationName ) ;
165
+ } else {
166
+ throw "no animation name" ;
167
+ }
168
+ } ) . then ( function ( canvasAnim ) { return canvasAnim . getSourceCodeString ( ) ;
169
+ } ) . then ( function ( codeString ) {
170
+ if ( canvasAnim . updateListener ) {
171
+ canvasAnim . updateListener ( canvasAnim . animationName , codeString ) ;
172
+ }
173
+ } ) . catch ( function ( e ) {
174
+ console . log ( e ) ;
163
175
} ) ;
164
176
165
177
} ) ;
0 commit comments