caleb531 / jcanvas

A jQuery plugin that makes the HTML5 canvas easy to work with.
https://projects.calebevans.me/jcanvas/
MIT License
626 stars 192 forks source link

getLayerGroup not working as expected #39

Closed dksmiffs closed 11 years ago

dksmiffs commented 12 years ago

Caleb,

Using jCanvas d0fba05872281517e99509d96730315e6b2b2f71 and jQuery 1.8.2, I can't make getLayerGroup work (tested on both FF 16.0.2 and Chromium-derived 22.0). The layers documentation for this function is a bit short, so perhaps I'm just not using the function as you intended? Here's the code I tried (note the very similar commented-out code that DOES animate the group):

$("canvas").addLayer({method: "drawRect", fillStyle: "#61c",
  group: "circleAndRect", opacity: 1.0, x: 210.0, y: 123.4,
  width: 75.0, height: 40.3})
.addLayer({method: "drawArc", fillStyle: "#1e6", group: "circleAndRect",
  opacity: 0.4, x: 200.0, y: 30.0, radius: 42.0})
.drawLayers();
var aLayerGrp = $("canvas").getLayerGroup("circleAndRect");
// DKS - as of 2012-10-29, the following line doesn't animate
$("canvas").animateLayerGroup(aLayerGrp, {y: 200, opacity: 0.3}, 4000,
// DKS - the following method (as an alternative to prior line) DOES animate
// $("canvas").animateLayerGroup("circleAndRect", {y: 200, opacity: 0.3},
//                               4000,
  function() {
// DKS - also 2012-10-29, doesn't work (depends on getLayerGroup above).
    $("canvas").setLayerGroup(aLayerGrp,
                              {fillStyle: "#A22", opacity: 1})
  }

~ Dave

caleb531 commented 12 years ago

Okay, I know what the issue is. Apparently, I forgot to make getLayerGroup() return the input if you pass it a layer group object. I applied the same behavior to getLayer() previously, but I forgot to also apply it to getLayerGroup(). And, because animateLayerGroup() uses this method internally, fixing the issue I described will also fix this issue. I'll see if I can push a fix to GitHub later tonight.

UPDATE: The Issue has been fixed in a recent commit.

-Caleb

On Oct 29, 2012, at 11:43 AM, dksmiffs notifications@github.com wrote:

Caleb,

Using jCanvas d0fba05 and jQuery 1.8.2, I can't make getLayerGroup work (tested on both FF 16.0.2 and Chromium-derived 22.0). The layers documentation for this function is a bit short, so perhaps I'm just not using the function as you intended? Here's the code I tried (note the very similar commented-out code that DOES animate the group):

$("canvas").addLayer({method: "drawRect", fillStyle: "#61c", group: "circleAndRect", opacity: 1.0, x: 210.0, y: 123.4, width: 75.0, height: 40.3}) .addLayer({method: "drawArc", fillStyle: "#1e6", group: "circleAndRect", opacity: 0.4, x: 200.0, y: 30.0, radius: 42.0}) .drawLayers(); var aLayerGrp = $("canvas").getLayerGroup("circleAndRect"); // DKS - as of 2012-10-29, the following line doesn't animate $("canvas").animateLayerGroup(aLayerGrp, {y: 200, opacity: 0.3}, 4000, // DKS - the following method (as an alternative to prior line) DOES animate // $("canvas").animateLayerGroup("circleAndRect", {y: 200, opacity: 0.3}, // 4000, function() { // DKS - also 2012-10-29, doesn't work (depends on getLayerGroup above). $("canvas").setLayerGroup(aLayerGrp, {fillStyle: "#A22", opacity: 1}) } ~ Dave

— Reply to this email directly or view it on GitHub.