我有一個工具提示(大圖像視圖),通過e.pageX e.pageY定位,我試圖確保它不隱藏在當前滾動視圖的下方港口。我如何獲得scrollbale窗口視口的相對尺寸
我見過很多網站都有這個 我的代碼是這樣的,但我錯過了一些東西。
var positionImg = function(e) {
var viewportWidth = $(window).width();
var viewportHeight = window.innerHeight ? window.innerHeight : $(window).height();
var mouseAtY = e.pageY;
var mouseAtX = e.pageX;
var maxBottomVPos = viewportHeight-"i dont know";
var maxTopVPos = 30;
if (mouseAtY >= maxBottomVPos)
{
tPosX = mouseAtX+ 10;
tPosY = mouseAtY -520;
}
else if (mouseAtY <= maxTopVPos)
{
tPosX = mouseAtX;
tPosY = mouseAtY +40;
}
else
{
tPosX = mouseAtX;
tPosY = mouseAtY +20;
}
$zoomContainer.css({top: tPosY, left: tPosX});
};
你是正確的,但我的問題是:「我如何得到屏幕的當前vewport當人體滾動」 視角圖像的http:// IMG .skitch.com/20090708-njwmg2fmrx23w6m8yau5axmn95.png – adardesign 2009-07-08 13:39:59
您已擁有視口高度。我想我知道你的意思,你需要滾動抵消? – geowa4 2009-07-08 14:38:59