如何在旋转元素上设置查询 UI 数组包含
How can I set a query UI array containment on a rotated element
这是一个带有数组包含(jquery UI)的可拖动图像的工作示例。
offsetLeft = $('#outerdiv').offset().left;
offsetTop = $('#outerdiv').offset().top;
blockWidth = $('#outerdiv').width();
blockHeight = $('#outerdiv').height();
imgWidth = $('#imgdrag').width();
imgHeight = $('#imgdrag').height();
x1 = offsetLeft + blockWidth - imgWidth;
y1 = offsetTop + blockHeight - imgHeight;
x2 = offsetLeft;
y2 = offsetTop;
$('#imgdrag').draggable({
containment: [x1,y1,x2,y2]
});
http://jsfiddle.net/yryFZ/8/
现在我旋转div并且我的遏制失败(不是显示整个图像,有时您可以看到红色背景颜色)。
http://jsfiddle.net/yryFZ/21/
旋转div 时如何重新计算或转换我的 x1/y1/x2/y2
试试这段代码:
blockWidth = $('#outerdiv').width();
blockHeight = $('#outerdiv').height();
imgWidth = $('#imgdrag').width();
imgHeight = $('#imgdrag').height();
leftBounder = ui.position.left;
topBounder = ui.position.top;
rightBounder = blockWidth - imgWidth;
bottomBounder = blockHeight - imgHeight;
if(ui.position.top > 0) { ui.position.top = 0; }
if(ui.position.left > 0) { ui.position.left = 0; }
if(topBounder < bottomBounder) { ui.position.top = bottomBounder; }
if(leftBounder < rightBounder) { ui.position.left = rightBounder; }
JSFiddle可以在这里找到:http://jsfiddle.net/kYN3J/3/
相关文章:
- ui路由器中基于查询的同级视图路由
- 带有查询字符串params的angular ui路由器空白页
- 查询UI可拖动值检查
- j查询带有下一个/上一个的 UI 选项卡
- j查询 UI 模式对话框在叠加单击时全局关闭
- 角度 ui 路由器可选查询参数加载控制器两次
- 角度 ui 路由器动态查询字符串定义
- 角度 UI 路由器使用查询参数更改状态
- 如何在旋转元素上设置查询 UI 数组包含
- AngularJS ui-router 使用 $state.params 和查询导航状态
- 具有查询 UI 折叠项的自定义绑定的选项设置
- SQL查询生成器Javascript UI
- 剑道ui网格查询参数
- 使用AngularJS UI路由器的复杂查询参数中的用户定义类型
- 角度 UI 路由器 - 状态查询字符串参数不起作用
- Angular ui-router不区分大小写的查询参数
- 查询UI的所有网站开发人员的任何语言
- Angular UI路由器将查询字符串放在哈希之前
- 在ui-router状态控制器中检索查询参数
- 如何使用SciptDb查询输出到UI标签文本