我正在使用Adam Shaw的FullCalendar v1.5.3。我已经得到了几乎所有的东西,可以接受我正在尝试做一个“简单的”hovertip,并且不能完全得到我要找的东西。FullCalendar:在鼠标悬停时,我如何判断事件悬停的左上角?
我想让我的工具提示的左侧与我悬停的事件的左侧相同。我试图让工具提示悬停在事件之上。
我目前使用的代码似乎给我一个“随机”左和顶部鼠标进入FullCalendar事件的地方。
我当前的代码看起来像:
eventMouseover: function (event, jsEvent, view) {
var eventInfo = $("#EventInfoTip");
var mousex = jsEvent.pageX + 20; //Get X coodrinates
var mousey = jsEvent.pageY + 20; //Get Y coordinates
var tipWidth = eventInfo.width(); //Find width of tooltip
var tipHeight = eventInfo.height(); //Find height of tooltip
//Distance of element from the right edge of viewport
var tipVisX = $(window).width() - (mousex + tipWidth);
//Distance of element from the bottom of viewport
var tipVisY = $(window).height() - (mousey + tipHeight);
if (tipVisX < 20) { //If tooltip exceeds the X coordinate of viewport
mousex = jsEvent.pageX - tipWidth - 20;
} if (tipVisY < 20) { //If tooltip exceeds the Y coordinate of viewport
mousey = jsEvent.pageY - tipHeight - 20;
}
//Absolute position the tooltip according to mouse position
eventInfo.css({ top: mousey, left: mousex });
eventInfo.show(); //Show tool tip
} //end full calendar mouseover event
EventInfoTip是页面上的简单跨度:
<span id = "EventInfoTip">
I'm over an event
</span>
是否有可能获得顶部和左侧,我徘徊在当前事件过度?
不知道这是否会帮助,因此为注释:http://api.jquery.com/offset/ – mindandmedia 2012-02-29 22:36:34