.offset() gets different values from IE7 for some reason?
I have an application I'm working on that allows a user to upload an image and put colored dots on POI's, then attach a tooltip to the dot and populate it with custom fields. In order to keep the dots inside the image while they're being created or dragged (drug?) around, I've created the following piece of code:
-
function limitCoords(x,y,objId,isNew)
{
if(isNew===true) modifier = -7.5;
else modifier = 0;
newX = x + modifier;
newY = y + modifier;
minX = Math.round($(objId).offset().left);
minX = minX==0 || minX==-2 ? defX : minX;
minY = Math.round($(objId).offset().top);
minY = minY==0 || minY==-2 ? defY : minY;
maxX = minX + parseInt($('#width').val()) - pointSize;
maxY = minY + parseInt($('#height').val()) - pointSize;
if(minX > x) newX = minX;
else if(maxX < x) newX = maxX;
if(minY > y) newY = minY;
else if(maxY < y) newY = maxY;
return {x:newX,y:newY};
}
The resulting array is used by the drag event handler to place the point against the edge of the image if the mouse goes off the edge. I've gotten it working in every browser my company officially supports,
except infernal IE7. It is placing the invisible "walls" at the top and bottom of the image exactly one point-width (15px) too high. Is this just (yet another) stupid IE7 quirk, or is there something obvious I'm doing wrong here?
(The objId parameter is always passed the html id of the image being drawn on, btw.)
This is absolutely infuriating, I have no earthly idea what's causing it, my project manager tells me we HAVE to fully support all "contemporary" browsers, and he is demoing this to the client on Friday afternoon! Please HELP!!