1

I can't figure out how to get the current rotation angle of an arch in jCanvas. layer.rotate only seems to provide me with the original setting of rotate, when I'd really like to change its behavior when it hits a certain angle.

I have an example setup on jsfiddle to demonstrate the problem.

Any insight would be appreciated.

Mike Shultz
  • 1,368
  • 1
  • 15
  • 32

2 Answers2

0

are you looking for this value $('#rot').val()

while (i < 1000) {
        setTimeout(function() { rotate() }, 1000);
        alert( $('#rot').val());
        i += 1;
    }
zod
  • 12,092
  • 24
  • 70
  • 106
0

The animateLayer() and animateLayerGroup() methods support the same alternate syntax as jQuery's animate() method, which allows for a step callback:

// Cache canvas element
var $canvas = $("canvas");

// Draw and animate
$canvas.drawArc({
  layer: true,
  name: 'arcy',
  fillStyle: "#000",
  x: 100, y: 100,
  radius: 50,
  start: 135, end: 45
});
$canvas.animateLayer('arcy', {
  rotate: 360
}, {
  // Use the step callback to run a function on every frame
  step: function(now, fx, layer) {
    console.log(layer.rotate);
  }
});
caleb531
  • 4,111
  • 6
  • 31
  • 41