diff --git a/misc/farbtastic/farbtastic.js b/misc/farbtastic/farbtastic.js index da87a0df8907c076bb8184675a74540f81cad488..028b00b3649acb957e9ad8facf3d36bdfca199a0 100644 --- a/misc/farbtastic/farbtastic.js +++ b/misc/farbtastic/farbtastic.js @@ -101,54 +101,8 @@ jQuery._farbtastic = function (container, callback) { * of the widget. */ fb.widgetCoords = function (event) { - var x, y; - var el = event.target || event.srcElement; - var reference = fb.wheel; - - // If the offset from the relative element is undefined calculate it. - if ( typeof event.offsetX == 'undefined' && typeof event.offsetY == 'undefined' ) { - var offset = $(event.target).offset(false); - event.offsetX = event.pageX - offset.left; - event.offsetY = event.pageY - offset.top; - } - - // Use offset coordinates and find common offsetParent - var pos = { x: event.offsetX, y: event.offsetY }; - - // Send the coordinates upwards through the offsetParent chain. - var e = el; - while (e) { - e.mouseX = pos.x; - e.mouseY = pos.y; - pos.x += e.offsetLeft; - pos.y += e.offsetTop; - e = e.offsetParent; - } - - // Look for the coordinates starting from the wheel widget. - var e = reference; - var offset = { x: 0, y: 0 }; - while (e) { - if (typeof e.mouseX != 'undefined') { - x = e.mouseX - offset.x; - y = e.mouseY - offset.y; - break; - } - offset.x += e.offsetLeft; - offset.y += e.offsetTop; - e = e.offsetParent; - } - - // Reset stored coordinates - e = el; - while (e) { - e.mouseX = undefined; - e.mouseY = undefined; - e = e.offsetParent; - } - - // Subtract distance to middle - return { x: x - fb.width / 2, y: y - fb.width / 2 }; + var offset = $(fb.wheel).offset(); + return { x: (event.pageX - offset.left) - fb.width / 2, y: (event.pageY - offset.top) - fb.width / 2 }; }; /**