Hey There,
I am trying to get a symbol to rotate and follow based on the cursor angle and I am running into an issue I can't track down. I am using sym. to decalre my variables so that I can reference them globally whithin my composition. But it looks like its something wrong with the diffAngle function.
Any thoughts?
Here is the code on get composition ready:
sym.x = e.pageX;
sym.y = e.pageY;
sym.centerItem = sym.getSymbol("mySymbol");
sym.centerLoc = centerItem.offset();
console.log( 'Center Item =' + sym.centerItem);
console.log( 'Center Loc =' + sym.centerLoc);
function diffAngle(){
sym.dx = sym.x - (sym.centerLoc.left + (sym.centerItem.width() / 2));
sym.dy = sym.y - (sym.centerLoc.position().top + (sym.centerItem.height() / 2));
sym.newAngle = Math.atan2(sym.dy, sym.dx) * (180 / Math.PI);
return sym.newAngle;
console.log( 'New Angle =' + sym.newAngle);
}
$('#Stage').mousemove(function(e){
sym.myAngle = sym.newAngle;
sym.rotationValue = 'rotate(' + sym.myAngle + 'deg)';
sym.$("mySymbol").css({
'-moz-transform': sym.rotationValue,
'-webkit-transform': sym.rotationValue,
'-o-transform': sym.rotationValue,
'-ms-transform': sym.rotationValue,
'transform': sym.rotationValue
});
console.log('Mouse Moving');
});