mTips.s('回调调整提示框位置
', 'success ', function(){
let tipWidth = $(".mTips").width();
let tipHeight = $(".mTips").height();
let tipLeft = $(".mTips").position().left;
let tipTop = $(".mTips").position().top;
let winWidth = document.body.clientWidth;
let winHeight = document.body.clientHeight;
let left = tipLeft + mTips.c.x;
let top = tipTop + mTips.c.y;
// 如果模块大于页面总宽或高,则重写计算位置
if (tipLeft + tipWidth > winWidth) {
left = tipLeft - tipWidth - mTips.c.x * 2;
}
if (tipTop + tipHeight > winHeight) {
top = tipTop - tipHeight - mTips.c.y * 2;
}
$(".mTips").offset({
top: top,
left: left
})
});使用时需要在mTips.js 60行处
$(document).on('mousemove'......{
...
// 添加回调
if (fun != null && typeof(fun) != 'undefined') {
fun();
}
}
回复