Skip to content

Commit e221470

Browse files
fix 2 bugs
1 parent 6d269ea commit e221470

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

public/editorController.js

+5
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,12 @@ define(['ui', 'net', 'evileval'], function(ui, net, evileval){
7171
};
7272

7373
var updateWithCanvasAnim = function(canvasAnim){
74+
if(currentCanvasAnim){
75+
currentCanvasAnim.updateListener = null;
76+
}
7477
currentCanvasAnim = canvasAnim;
78+
currentCanvasAnim.updateListener = view.setEditorContent;
79+
7580
canvasAnim.getSourceCodeString().then(function(codeString){
7681
view.setEditorContent(canvasAnim.animationName, codeString);
7782
});

public/exquis.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ define(["iter2d", "csshelper", "evileval", "net", "ui"], function(iter2d, csshel
3030

3131
var makeCanvasAnimation = function(context){
3232
return {
33+
updateListener:null,
3334
currentCode: null,
3435
context: context, //might be useful to debug
3536
borders : function(){
@@ -81,6 +82,7 @@ define(["iter2d", "csshelper", "evileval", "net", "ui"], function(iter2d, csshel
8182
},
8283

8384
getSourceCodeString: function(){
85+
//TODO continue refactoring here, see doc.org
8486
if (this.uri.match(/^data:/)){
8587
// the code is in the cache
8688
return new Promise(function(resolve, reject){
@@ -157,9 +159,19 @@ define(["iter2d", "csshelper", "evileval", "net", "ui"], function(iter2d, csshel
157159
var names = fileUris.map(store.uriToAnimationName);
158160
return ui.populateNamePicker("choose animation", names);
159161
}).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);
163175
});
164176

165177
});

todo.org

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ par exemple en mettant les boutons de l'animation à coté de son nom, ou les me
1313
** remplacer setInterval par requestAnimation
1414
* new animations
1515
* bugs
16+
** TODO animation name is displayed incorectly the second time you click on edit cell button
17+
net.extractAnimationNameFromUri cannot deduce the name from a data uri
18+
this problem will be solved when we introduce the distinction between canvasAnim.originalUrl and .codeUri
19+
1620
* implement blockly interface https://code.google.com/p/blockly/
1721
* allow usage of files from external urls (github.com, pastebin, etc)
1822
define a assemblage file with urls

0 commit comments

Comments
 (0)