楔子
easyui 防止 拖拽出边界,
js
outOfBounds.js
var easyuiPanelOnMove = function(left, top) {
var l = left;
var t = top;
if (l < 1) {
l = 1;
}
if (t < 1) {
t = 1;
}
var width = parseInt($(this).parent().css('width')) + 14;
var height = parseInt($(this).parent().css('height')) + 14;
var right = l + width;
var buttom = t + height;
var browserWidth = $(window).width();
var browserHeight = $(window).height();
if (right > browserWidth) {
l = browserWidth - width;
}
if (buttom > browserHeight) {
t = browserHeight - height;
}
$(this).parent().css({/* 修正面板位置 */
left : l,
top : t
});
};
$.fn.dialog.defaults.onMove = easyuiPanelOnMove;
$.fn.window.defaults.onMove = easyuiPanelOnMove;
$.fn.panel.defaults.onMove = easyuiPanelOnMove;
使用
上述写在一个js(outOfBounds.js)文件中,需要用到的页面引入
<script src="${pageContext.request.contextPath }/js/easyui/outOfBounds.js" type="text/javascript"></script>
这是之前看到的,做个记录。