KateRaman / simile-widgets

Automatically exported from code.google.com/p/simile-widgets
0 stars 0 forks source link

TIMELINE. Scrolling with mouse fails in IE when you you start over a label #228

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When you double click or click and drag on a label, scrolling breaks. This
is due to a bug in Timeline.DOM.getEventRelativeCoordinates where the code
for IE doesn't take into account that the timeline-band contains other
elements like labels and such.

The following patch fixes the issue:

=== modified file 'simile/scripts/util/dom.js'
--- simile/scripts/util/dom.js 2007-09-07 12:35:14 +0000
+++ simile/scripts/util/dom.js 2007-11-15 16:32:02 +0000
@@ -51,19 +51,30 @@
     return { left: left, top: top };
 };

+Timeline.DOM.getMouseCoordinates = function(evt) {
+ var posx = 0;
+ var posy = 0;
+
+ if (evt.pageX || evt.pageY) {
+ posx = evt.pageX;
+ posy = evt.pageY;
+ }
+ else if (evt.clientX || evt.clientY) {
+ posx = evt.clientX + document.body.scrollLeft
+ + document.documentElement.scrollLeft;
+ posy = evt.clientY + document.body.scrollTop
+ + document.documentElement.scrollTop;
+ }
+ return {'x': posx, 'y': posy };
+};
+
 Timeline.DOM.getEventRelativeCoordinates = function(evt, elmt) {
- if (Timeline.Platform.browser.isIE) {
- return {
- x: evt.offsetX,
- y: evt.offsetY
- };
- } else {
- var coords = Timeline.DOM.getPageCoordinates(elmt);
- return {
- x: evt.pageX - coords.left,
- y: evt.pageY - coords.top
- };
- }
+ var page = Timeline.DOM.getMouseCoordinates(evt);
+ var coords = Timeline.DOM.getPageCoordinates(elmt);
+ return {
+ x: page.x - coords.left,
+ y: page.y - coords.top
+ };
 };

 Timeline.DOM.cancelEvent = function(evt) {
IE 6.0, IE 7.0 

[Submitted by Alf Lervåg on simile.mit.edu]

Original issue reported on code.google.com by GabrielR...@googlemail.com on 8 Apr 2009 at 2:37