Skip to content

Commit afc26e4

Browse files
committed
Fixed a bug in the drawing of all the graphs, especially visible in easeout curves. Added a top line to each graph. Added support for linear graph and preview. Slowed animation down a bit, to aid in preview.
1 parent 9c41ecc commit afc26e4

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

demos/effect/easing.html

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
height = 100;
2424
$.each($.easing, function(name, impl) {
2525
// skip linera/jswing and any non functioning implementation
26-
if (!$.isFunction(impl) || /linear|jswing/.test(name))
26+
if (!$.isFunction(impl) || /jswing/.test(name))
2727
return;
2828
var graph = $("<div/>").addClass("graph").appendTo("#graphs");
2929
var text = $("<div/>").text(++i + ". " + name).appendTo(graph);
3030

3131
var canvas = $("<canvas/>").appendTo(graph)[0]
3232
canvas.width = width;
3333
canvas.height = height;
34-
var drawHeight = height * 0.75;
34+
var drawHeight = height * 0.8;
3535
var cradius = 10;
3636
var ctx = canvas.getContext("2d");
3737
ctx.fillStyle = "black";
@@ -49,19 +49,27 @@
4949

5050
ctx.strokeStyle = "#555";
5151
ctx.beginPath();
52-
ctx.moveTo(0, drawHeight + .5);
53-
ctx.lineTo(width, drawHeight + .5);
52+
ctx.moveTo(width * 0.1, drawHeight + .5);
53+
ctx.lineTo(width * 0.9, drawHeight + .5);
54+
ctx.stroke();
55+
56+
ctx.strokeStyle = "#555";
57+
ctx.beginPath();
58+
ctx.moveTo(width * 0.1, drawHeight * .3 - .5);
59+
ctx.lineTo(width * 0.9, drawHeight * .3 - .5);
5460
ctx.stroke();
5561

5662
ctx.strokeStyle = "white";
5763
ctx.lineWidth = 2;
5864
ctx.beginPath();
5965
$.each(new Array(width), function(position) {
60-
ctx.lineTo(position, drawHeight - position * impl(0, position, 0, 1, height) * 0.75);
66+
var val = impl(0, position, 0, 1, height);
67+
if (/linear|jswing/.test(name)) val = position / width;
68+
ctx.lineTo(position * 0.8 + width * 0.1, drawHeight - drawHeight * val * 0.7);
6169
});
6270
ctx.stroke();
6371
graph.click(function() {
64-
$(canvas).animate({height: "hide"}, "slow", name).animate({"left": "0"}, 800).animate({height: "show"}, "slow", name);
72+
$(canvas).animate({height: "hide"}, 2000, name).animate({"left": "0"}, 800).animate({height: "show"}, 2000, name);
6573
});
6674

6775
graph.width(width).height(height + text.height() + 10);

0 commit comments

Comments
 (0)