From 5602a166ea3be0f66d2477b3c6f57e730272c8f6 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 16 Dec 2013 12:21:54 -0500 Subject: + add frame, sortable frames --- shader-gif.html | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'shader-gif.html') diff --git a/shader-gif.html b/shader-gif.html index 49e4ac0..f99aaba 100644 --- a/shader-gif.html +++ b/shader-gif.html @@ -6,8 +6,10 @@ #url { width: 100px; } #width,#height,#frames,#delay {width: 30px; } #shader { width: 400px; height: 247px; font-family: fixed; } -#frames { width: 400px; height: 100px; overflow-x: scroll; } +#frames { width: 400px; height: 100px; } #controls { width: 450px; } +#frames div { padding: 1px; } +#frames .remove { position: absolute; top: 5px; right: 5px; color: #f00; } div { float: left; padding: 10px;} @@ -38,6 +40,7 @@ delay + @@ -46,6 +49,7 @@ delay var cc = cq(0,0).appendTo("#workspace") var w, h +var dragging = false $(init) @@ -53,8 +57,14 @@ function init(){ $("#url").change(load) $("#reset").click(reset) $("#pause").click(pause) + $("#add-frame").click(add_frame) $("#demo").click(function(){ demo("#first") }) $("#dither-demo").click(function(){ demo("#second") }) + $("#frames").sortable({ + start: function(){ dragging = true }, + stop: function(){ dragging = false } + }); + $("#frames").disableSelection(); demo('#first') load() draw() @@ -81,7 +91,7 @@ function pause(){ var timeout = null, raf_id, start_t = 0, old_t = 0, pause_t = 0, paused = false; function draw(t){ raf_id = requestAnimationFrame(draw); - if (paused) { + if (paused || dragging) { pause_t += t - old_t old_t = t return @@ -135,14 +145,20 @@ function shade(frame, t){ } } -frames = [] function add_frame(){ - var cel = cc.clone().appendTo("#frames") - frames.push(cel) + var $el = $("
") + $el.html( $("#frame-template").html() ) + var frame = cc.clone() + var thumb = cc.clone().resize(100,100).appendTo($el.find(".frame")[0]) + $("#frames").append($el) } function remove_frame(){ } +