1

当我在旋转后更改 css3 中的 transform-origin 属性时,元素会跳回原始位置的中心。有没有办法计算这个距离?我想在不同的原点进行平滑的旋转。

我写了一个公式。它运作良好,但前提是我知道未来轮换的起源。

var newx = p2x - Math.sqrt(Math.pow(p2x - p1x, 2) + Math.pow(p2y - p1y, 2)) * Math.sin( -((degree * (Math.PI/180))) + Math.atan( ((p2x - p1x)/(p2y - p1y)) ));
var newy = p2y - Math.sqrt(Math.pow(p2x - p1x, 2) + Math.pow(p2y - p1y, 2)) * Math.cos( -((degree * (Math.PI/180))) + Math.atan( ((p2x - p1x)/(p2y - p1y)) ));

p1x 和 p1y 是未来的值,p2x 和 p2y 是当前旋转的原点。

4

0 回答 0