[英]Resize logic to maintain a fixed corner after rotate in javascript
How to calculate or logic behind to get translate x & y while resize(with one fixed corner) after rotate.旋转后如何在调整大小(具有一个固定角)时计算或背后的逻辑以获取平移 x 和 y。
rotate:0deg
)rotate:0deg
) I handled center based rotate and resize without any problem.我处理了基于中心的旋转和调整大小没有任何问题。
But the problem is, i need a fixed corner when resize a rotated div.但问题是,在调整旋转 div 的大小时,我需要一个固定的角。
When resize a rotated div, using bottom-right handle, top-left needs to remains fixed , likewise opposite corners need to fixed position.调整旋转后的 div 大小时,使用右下手柄,左上角需要保持固定,同样对角需要固定位置。
<div class="box" style="transform: translate(132px, 190px) rotate(45deg); width: 295px; height: 234px;">
<div>
function rotate(){
//Here i update angle
}
function resize(){
//Here i update translate x & y, width & height
switch (handle) {
case 'bottom-right':
x = previous_x - ? ; // logic to get translate x when resize a rotated div.
y = previous_y + ? ; // logic to get translate y when resize a rotated div.
break;
case 'bottom-left':
x = previous_x - ? ;
y = previous_y + ? ;
break;
case 'top-left':
x = previous_x - ? ;
y = previous_y + ? ;
break;
case 'top-right':
x = previous_x - ? ;
y = previous_y + ? ;
break;
default:
}
}
I checked Canva website, the transform manager div translate x and y gets updated while resize a rotated div to maintain a fixed corner .我检查了Canva网站,变换管理器 div translate x 和 y 在调整旋转 div 的大小以保持固定的角时得到更新。
Anybody help me to calculate translate x and y values using rotated angle to maintain a fixed corner.任何人都可以帮助我使用旋转角度来计算平移 x 和 y 值以保持固定角。
Thanks in Advance.提前致谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.