Zoom page -> Mouse position wrong?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DJ WIce

    Zoom page -> Mouse position wrong?

    Hi,

    I have a function on my page to zoom in (for people who have not very good
    eyes for example):

    var zoom_factor=100 ;
    function zoom(how)
    {
    var bodyStyle = document.body.s tyle;
    zoom_factor = (how)?100:110;
    zoomed = bodyStyle.zoom;
    if ((zoomed)&&(zoo m_factor!=100))
    zoom_factor=par seInt(zoomed)*p arseInt(zoom_fa ctor)/100;
    bodyStyle.setAt tribute('zoom', parseInt(zoom_f actor)+'%');
    }


    I also have a function to locate the mouse cursor:

    var x, y;
    function TraceMouse(e)
    {
    x = (document.all) ? document.body.s crollLeft + event.clientX : e.pageX;
    y = (document.all) ? document.body.s crollTop + event.clientY : e.pageY;
    flag = 1;
    }
    if (!document.all)
    document.captur eEvents(Event.M OUSEMOVE);
    document.onmous emove = TraceMouse;


    Now I want to write some menu on the place where the mouse is oncontextmenu.
    But when the page is zoomed in, the menu is placed more down than usual.

    The page (just a page I make to test what is possible with javascript):

    The script:


    If anyone has ideas why it goes wrong, please let me know.
    Thanks,
    Wouter



  • DJ WIce

    #2
    Re: Zoom page -> Mouse position wrong?

    Problem solved:

    If one zooms the mouse position is the location on the not zoomed page.
    But the placement pixels are the position on the new page.
    So one need to correct for the zoom_factor.

    Wouter

    "DJ WIce" <contextmenu@dj wice.com> wrote in message
    news:bumnda$hpa $1@news.tudelft .nl...
    : Hi,
    :
    : I have a function on my page to zoom in (for people who have not very good
    : eyes for example):
    :
    : var zoom_factor=100 ;
    : function zoom(how)
    : {
    : var bodyStyle = document.body.s tyle;
    : zoom_factor = (how)?100:110;
    : zoomed = bodyStyle.zoom;
    : if ((zoomed)&&(zoo m_factor!=100))
    : zoom_factor=par seInt(zoomed)*p arseInt(zoom_fa ctor)/100;
    : bodyStyle.setAt tribute('zoom', parseInt(zoom_f actor)+'%');
    : }
    :
    :
    : I also have a function to locate the mouse cursor:
    :
    : var x, y;
    : function TraceMouse(e)
    : {
    : x = (document.all) ? document.body.s crollLeft + event.clientX : e.pageX;
    : y = (document.all) ? document.body.s crollTop + event.clientY : e.pageY;
    : flag = 1;
    : }
    : if (!document.all)
    : document.captur eEvents(Event.M OUSEMOVE);
    : document.onmous emove = TraceMouse;
    :
    :
    : Now I want to write some menu on the place where the mouse is
    oncontextmenu.
    : But when the page is zoomed in, the menu is placed more down than usual.
    :
    : The page (just a page I make to test what is possible with javascript):
    : http://www.djwice.com/contextmenu.html
    : The script:
    : http://www.djwice.com/contextmenu/contextmenu.js
    :
    : If anyone has ideas why it goes wrong, please let me know.
    : Thanks,
    : Wouter
    :
    :
    :


    Comment

    Working...