我在互联网上搜索了很多地方,虽然我发现了这篇关于堆栈溢出的文章,很有见地,但是它仍然没有回答我的问题,可能是由于我对位置/偏移的理解有困难。
这就是我要做的。我希望 Twitter 引导弹出窗口的位置是正确的,除非热点弹出窗口将定位在视窗之外,然后我希望它被定位在左边。我正在制作一个 iPad 网络应用程序,它有热点,当你按下热点时,信息就会出现,但是当水平滚动被锁定时,我不希望它出现在视窗之外。
我觉得应该是这样的:
$('.infopoint').popover({
trigger:'hover',
animation: false,
placement: wheretoplace
});
function wheretoplace(){
var myLeft = $(this).offset.left;
if (myLeft<500) return 'left';
return 'right';
}
有什么想法吗,谢谢!