From beb6a880100835aa44b8508a03b3b0b63562055a Mon Sep 17 00:00:00 2001 From: jules Date: Sun, 26 Jan 2014 04:22:07 -0500 Subject: nicer loading logic --- js/frames.js | 11 ++++++----- js/image.js | 1 + js/render.js | 8 ++++++-- shader-combo.html | 32 ++++++++++++++++++-------------- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/js/frames.js b/js/frames.js index 1d08807..887b497 100644 --- a/js/frames.js +++ b/js/frames.js @@ -54,7 +54,6 @@ function add_single_frame(){ frame.canvas.style.display = "none" var thumb = cc.clone().resize(frame_thumb_size,frame_thumb_size).appendTo($el.find(".frame")[0]) $("#frames").append($el) - $("#render").enable() } function add_frames(frame_count){ rendering = true @@ -71,9 +70,6 @@ function add_frames(frame_count){ } function remove_frame(){ $(this).closest("div").remove() - if ($("#frames div").length == 0) { - $("#render").disable() - } } function remove_all_frames(){ $("#frames").empty() @@ -102,6 +98,11 @@ function sort_frames(){ function render (){ if (rendering) return rendering = true + + if ($("#frames canvas.fullsize").length == 0) { + add_frame() + } + encoder.reset() var delay = $("#framedelay").float() * 1000 || 100 $("#frames canvas.fullsize").each(function(){ @@ -149,7 +150,7 @@ encoder.on("rendered-url", function(url){ $("#uploaded-url").hide().val("") $("#save,#upload,#rendered").show() $("#pause,#render,#add-frame,#save,#upload").enable() - $("#render").html("render") + $("#render").html("render gif") rendering = false pause(true) }) diff --git a/js/image.js b/js/image.js index 4de7fd9..aabab89 100644 --- a/js/image.js +++ b/js/image.js @@ -2,6 +2,7 @@ var gif, img function loadImage(imageURL, callback) { var imageURL = proxify( imageURL ); + window.imageURL = imageURL window.gif = window.img = null diff --git a/js/render.js b/js/render.js index 6ad7560..cfc2d81 100644 --- a/js/render.js +++ b/js/render.js @@ -12,13 +12,17 @@ function choose (){ } function load(){ - var imageURL = $("#url").val() + var newImageURL = $("#url").val() loading = true - loadImage(imageURL, ready) + if (newImageURL != imageURL) { + loadImage(newImageURL, ready) + status("loading") + } } function ready(){ loading = false + status("") if (window.gif) { frame = gif.frames[0] actual_w = w = cc.canvas.width = frame.ctx.canvas.width diff --git a/shader-combo.html b/shader-combo.html index 3c28b54..f51037b 100644 --- a/shader-combo.html +++ b/shader-combo.html @@ -2,7 +2,7 @@ @@ -99,23 +101,20 @@ form { display: inline-block; }
- - + + + +
+
- - - -
- -
-
- - frames +
+ + frames -


+ gif delay background +   + + + +
-- cgit v1.2.3-70-g09d2