Potentially fix Issue 193: Use inverse of screen CTM on mouse event coordinates to get to relative SVG coordinates

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@865 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Jeff Schiller 2009-10-22 03:07:15 +00:00
parent 18a9d20cfd
commit 5ade7006c1
1 changed files with 19 additions and 8 deletions

View File

@ -1539,8 +1539,12 @@ function BatchCommand(text) {
// and do nothing else
var mouseDown = function(evt)
{
var mouse_x = evt.pageX - container.parentNode.offsetLeft + container.parentNode.scrollLeft - container.offsetLeft;
var mouse_y = evt.pageY - container.parentNode.offsetTop + container.parentNode.scrollTop - container.offsetTop;
var sctm = svgroot.getScreenCTM().inverse();
var pt = svgroot.createSVGPoint();
pt.x = evt.pageX; pt.y = evt.pageY;
pt = pt.matrixTransform(sctm);
var mouse_x = pt.x;
var mouse_y = pt.y;
evt.preventDefault();
@ -1843,8 +1847,12 @@ function BatchCommand(text) {
{
if (!started) return;
var selected = selectedElements[0];
var mouse_x = evt.pageX - container.parentNode.offsetLeft + container.parentNode.scrollLeft - container.offsetLeft;
var mouse_y = evt.pageY - container.parentNode.offsetTop + container.parentNode.scrollTop - container.offsetTop;
var sctm = svgroot.getScreenCTM().inverse();
var pt = svgroot.createSVGPoint();
pt.x = evt.pageX; pt.y = evt.pageY;
pt = pt.matrixTransform(sctm);
var mouse_x = pt.x;
var mouse_y = pt.y;
var shape = svgdoc.getElementById(getId());
x = mouse_x / current_zoom;
@ -2598,8 +2606,12 @@ function BatchCommand(text) {
justSelected = null;
if (!started) return;
var mouse_x = evt.pageX - container.parentNode.offsetLeft + container.parentNode.scrollLeft - container.offsetLeft;
var mouse_y = evt.pageY - container.parentNode.offsetTop + container.parentNode.scrollTop - container.offsetTop;
var sctm = svgroot.getScreenCTM().inverse();
var pt = svgroot.createSVGPoint();
pt.x = evt.pageX; pt.y = evt.pageY;
pt = pt.matrixTransform(sctm);
var mouse_x = pt.x;
var mouse_y = pt.y;
var x = mouse_x / current_zoom;
var y = mouse_y / current_zoom;
@ -2705,7 +2717,6 @@ function BatchCommand(text) {
case "square":
case "rect":
keep = (element.width.baseVal.value && element.height.baseVal.value);
console.log([keep,element.getAttribute('width'),element.getAttribute('height')]);
break;
case "image":
keep = (element.width.baseVal.value && element.height.baseVal.value);