jquery ui 可调整大小 : resizing the rotated objects

标签 jquery jquery-ui rotation jquery-ui-resizable

问题:

Jquery-ui-ressized 似乎无法正确处理旋转的对象。旋转元素后, handle 会执行与未旋转元素相同的操作。

想法:

轴可能可以根据旋转矩阵( http://en.wikipedia.org/wiki/Rotation_matrix )旋转。所以我想我们可以通过 x' = x*cos(a) -y*sin(a); y' = x*sin(a) + y*cos(a) 获得更新的鼠标坐标.

有人见过类似的解决方案(补丁或用于调整大小的独立 jquery 插件)吗? 如果我重写_mouseStart,任何人都可以给我建议吗?和_mouseDrag jquery.ui.ressized 的方法?

最佳答案

好吧,我终于回到了我的问题并取得了一些进展:https://github.com/andyzee/jquery-resizable-rotation-patch 我决定现在不使用旋转矩阵(尽管它实际上有效),而是切换处理程序

function switchAxis(axis, angle) {
    while(angle >= 360) angle = 360-angle;
    while(angle < 0) angle = 360+angle;
    var axisArray = ["n", "ne", "e", "se", "s", "sw", "w", "nw"];
    var octant = Math.round(angle/45); // 0 .. 7
    var index = 0;
    if ( [].indexOf ) {
        index = axisArray.indexOf(axis);
    } else {
        for(var i=0; i<axisArray.length; i++) {
            if (axisArray[i] === axis) index = i;
        }
    }
    var newAxisIndex = (index + octant) % 8;
    return axisArray[newAxisIndex];
}

我肯定会继续我的搜索,并且可能会编写自己的解决方案。

关于jquery ui 可调整大小 : resizing the rotated objects,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16775924/

相关文章:

jquery anchor 上的点击事件

javascript - JQuery .on 仅在动态生成的元素上触发一次

php - 使用 AJAX 检索 JSON 数据

jquery-ui - jQuery : How to clear an element before appending new content?

jquery-ui - 移动 joomla 和 jquery ui 冲突

javascript - Canvas 正在绘制旋转图像

javascript - 围绕不断变化的原点旋转 - Javascript

jquery - 在 IE9 中重复添加样式时,Div 偶尔会丢失其变换状态

javascript - jQuery UI 自动完成停止工作

css - 如何将 .rotate() 混合应用于 Bootstrap 的 <i> 图标字形元素?