Skip to content

Commit

Permalink
Added new .delayLayerGroup() and .stopLayerGroup() methods
Browse files Browse the repository at this point in the history
Also fixed a bug when drawing text
  • Loading branch information
Caleb Evans committed Aug 14, 2012
1 parent 4af05f1 commit 7501e28
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 35 deletions.
38 changes: 35 additions & 3 deletions jcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -927,16 +927,48 @@ $.fn.delayLayer = function(name, duration) {
return $elems;
};

// Delay animation all layers in a layer group
$.fn.delayLayerGroup = function(name, duration) {
var $elems = this, $elem, e,
group, g;
duration = duration || 0;

for (e=0; e<$elems.length; e+=1) {
$elem = $($elems[e]);
group = $elem.getLayerGroup(name);
// Delay all layers in the group
for (g=0; g<group.length; g+=1) {
$elem.delayLayer.call($elem, name, duration);
}
}
};

// Stop layer animation
$.fn.stopLayer = function(name, clearQueue) {
var $elems = this, e, layer;

for (e=0; e<$elems.length; e+=1) {
layer = $($elems[e]).getLayer(name);
$(layer).stop(clearQueue);
}
return $elems;
};

// Stop animation of all layers in a layer group
$.fn.stopLayerGroup = function(name, clearQueue) {
var $elems = this, $elem, e,
group, g;

for (e=0; e<$elems.length; e+=1) {
$elem = $($elems[e]);
group = $elem.getLayerGroup(name);
// Delay all layers in the group
for (g=0; g<group.length; g+=1) {
$elem.stopLayer.call($elem, name, clearQueue);
}
}
};

// Enable animation for color properties
function supportColorProps(props) {
var p;
Expand Down Expand Up @@ -1514,9 +1546,7 @@ $.fn.drawText = function self(args) {
ctx.font = params.font;

// Retrieve text layer's width and height
if (params.layer) {
measureText($elems[e], ctx, params);
}
measureText($elems[e], ctx, params);
transformShape(e, ctx, params, params.width, params.height);

ctx.fillText(params.text, params.x, params.y);
Expand Down Expand Up @@ -1546,6 +1576,8 @@ $.fn.drawText = function self(args) {
}
cache.text = params.text;
cache.font = params.font;
cache.width = params.width;
cache.height = params.height;
return $elems;
};

Expand Down
Loading

0 comments on commit 7501e28

Please sign in to comment.