0

我有一个帆布 tube1Ctx 和一个 id 为 sineWave 的 div。使用纯 Javascript 在鼠标拖动时旋转画布。现在我需要相对于画布同时旋转 div(相同的角位移)。当我尝试使用以下代码时,拖动旋转画布时变换样式不会更新。有人可以帮我解决吗?

function tubeRotate(e){
    
    if (moveFlag2){
    
    tube1XPos = e.clientX - tube1Canvas.offsetLeft;
    tube1YPos = e.clientY - tube1Canvas.offsetTop;  
    
        
    rotate = tube1XPos-((e.clientX-tube1Canvas.offsetLeft));    
    rotate = (Math.atan(240/rotate))* Math.PI / 180;
    tube1Ctx.clearRect(240,10,tube1Canvas.width,tube1Canvas.height);    
    tube1Ctx.translate(275, 10);
    tube1Ctx.rotate(rotate);    
    tube1Ctx.translate(-275,-10 );  
    tube1Ctx.drawImage(tube1Img,240 , 10 , 46 , 235 );
    

        var angle=rotate;

    document.getElementById("sineWave").style.MozTransformOrigin='0% 0%';
    document.getElementById("sineWave").style.MozTransform =  'rotate('+angle+'rad)';
    
    document.getElementById("sineWave").style.webkitTransformOrigin='0% 0%';
    document.getElementById("sineWave").style.webkitTransform = 'rotate('+angle+'rad)';
}
4

1 回答 1

1

缺少报价

document.getElementById("sineWave).style.MozTransformOrigin='0% 0%';

于 2012-04-10T12:26:43.080 回答