6G Celicas Forums

Welcome Guest ( Log In | Register )

> Floating DIV Thread Preview Thungy
post Jun 29, 2006 - 6:47 PM
+Quote Post
tomazws



Enthusiast
*****
Joined Oct 30, '04
From So Cal
Currently Offline

Reputation: 13 (100%)




Coomer,

It's not much of a big deal anyway. But for Safari browsers, the more a page is scrolled down, the floating div (with preview of the thread's content) will appear further and further below the mouse pointer to a point it goes outside of the browser's viewable area.

I took a look into the source, and provided you with a fix (please confirm though). Hopefully this will help improve your website. smile.gif

Under: http://www.6gc.net/forums/sources/action_p.../TPH/d21_tph.js
CODE

function preview_do(e)
{
    cx = (ns5) ? e.pageX : event.x+tbody().scrollLeft;
    cy = (ns5) ? e.pageY : event.y+tbody().scrollTop;

    var r = ((ie4 || ie5) && !window.opera) ? tbody().clientWidth-event.clientX-ox  : window.innerWidth-e.clientX-ox-20;
    var b = ((ie4 || ie5) && !window.opera) ? tbody().clientHeight-event.clientY-oy : window.innerHeight-e.clientY-oy-20;
    var l = (ox < 0) ? ox*(-1) : -1000;

    if (r < obj.offsetWidth)
    {
        obj.style.left = (ie4 || ie5) ? tbody().scrollLeft+event.clientX-obj.offsetWidth+'px' : window.pageXOffset+e.clientX-obj.offsetWidth+'px';
    }
    else if (cx < l)
    {
        obj.style.left = '5px';
    }
    else
    {
        obj.style.left = cx+ox+'px';
    }

    if (b < obj.offsetHeight)
    {
        obj.style.top = (ie4 || ie5) ? tbody().scrollTop+event.clientY-obj.offsetHeight-oy+'px' : window.pageYOffset+e.clientY-obj.offsetHeight-oy+'px';
    }
    else
    {
        obj.style.top = cy+oy+'px';
    }
}


you could replace the above function with the following fix (or at least... believed to be a fix):
CODE

function preview_do(e)
{
    if (typeof e != "undefined") {
        ox = e.pageX;
        oy = e.pageY;
    } else if (typeof window.event !="undefined") {
        ox = tbody().scrollLeft + event.clientX
        oy = tbody().scrollTop + event.clientY
    }
    var docwidth = document.all? tbody().scrollLeft + tbody().clientWidth : pageXOffset + window.innerWidth - 20;
    var docheight = document.all? tbody().scrollTop + tbody().clientHeight : pageYOffset + window.innerHeight;
    if (ox + obj.offsetWidth > docwidth) {
        obj.style.left = ox - obj.offsetWidth + "px";
    } else {
        obj.style.left = ox + "px";
    }
    if (oy + obj.offsetHeight > docheight) {
        obj.style.top = oy - obj.offsetHeight + "px";
    } else {
        obj.style.top = oy + "px";
    }
}



Cheers


--------------------
 
Start new topic
Replies (1 - 1)
post Jun 29, 2006 - 9:45 PM
+Quote Post
Coomer



Administrator
*****
Joined Aug 23, '02
From Seattle, WA
Currently Offline

Reputation: 14 (100%)




Thanks for the code...I'll look at it in depth when I get back to my apt. after the weekend. smile.gif


--------------------
New Toyota project coming soon...

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: November 29th, 2024 - 11:52 PM