0
我在5分鐘內凍結應用的Cordova應用(Android)中的主幹中使用腳本,無論如何我無法做到不同的方式。凍結之前刷新主幹
所以我想在腳本運行之前加載一條消息,但視圖沒有更新。
我可以等待視圖的更新以使用事件運行腳本嗎?
下面是代碼:
touchable.get("canvas").$el.parent().hide(); // A canvas to be hidden, but still on screen
this.$el.show(); // The view to replace canvas elem, didn't show up on screen
this.model.draw_full_image(); // Freezing
EDIT
裝載視圖:
var SavingView = Backbone.View.extend({
el: '.saving',
show: function() {
touchable.get("canvas").$el.parent().hide();
this.$el.show();
this.model.draw_full_image(); // Long script
},
hide: function() {
// Show the canvas again, after freeze
}
});
畫布視圖:
var Canvas = Backbone.View.extend({
tagName: "canvas",
initialize: function() {
this.ctx = this.$el[0].getContext("2d");
},
render: function() {
$(".canvas").append(this.$el);
this.el.width = screen_size.w;
this.el.height = screen_size.h - this.$el.offset().top;
},
clear: function() {
this.ctx.clearRect(0, 0, this.el.width, this.el.height);
},
draw_full_image: function(e) {
// Long process here
},
// Saving image (part of process)
save: function(canvas_model) {
window.canvas2ImagePlugin.saveImageDataToLibrary(
function(msg){
saving.hide();
window.plugins.toast.show("La photo a bien été enregistrée !", "long", "bottom");
},
function(err){
saving.hide();
window.plugins.toast.show("Une erreur s'est produite lors de l'enregistrement, veuillez réessayer.", "long", "bottom");
},
canvas_model
);
}
});
我不能這樣做,因爲我的視圖是隱藏的(我想顯示它)。我有一個畫布,我想隱藏它來顯示一條消息。但我不想刪除任何元素:/。看到新代碼 –
是'touchable.get(「canvas」)'另一種視圖? –
是的,這是我想要隱藏的div中的畫布視圖。 –