Changeset 17719 for trunk


Ignore:
Timestamp:
04/28/14 20:21:46 (11 years ago)
Author:
tbretz
Message:
Fixed the pixel click issue on firefox... and hopefully other browsers as well.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/www/viewer/index.js

    r17717 r17719  
    766766        return;
    767767
    768     var mouse = getClickPosition();
     768    // get click position relative to canvas
     769    var rect = event.target.getBoundingClientRect();
     770
     771    var x =  event.clientX - rect.left;
     772    var y =  event.clientY - rect.top;
     773
     774    var mouse = { x: x, y: y };
     775
     776    // convert click position to pixel index
    769777    var index = getIndex(event.target.id, mouse);
    770 
    771778    if (index<0)
    772779        return;
     
    779786function getClickPosition(event)
    780787{
    781     var event = window.event;
    782 
    783     if (event.offsetX !== undefined && event.offsetY !== undefined)
    784         return { x: event.offsetX, y: event.offsetY };
    785 
    786     return { x: event.layerX, y: event.layerY };
     788    var rect = event.target.getBoundingClientRect();
     789
     790    var x =  event.clientX - rect.left;
     791    var y =  event.clientY - rect.top;
     792
     793    return { x: x, y: y };
    787794}
    788795
Note: See TracChangeset for help on using the changeset viewer.