Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #5174 (closed defect: invalid)

Opened 2 years ago

Last modified 2 years ago

Wrong Position returned for Droppable element that is within a scrolled DIV container

Reported by: chunpan.geo@yahoo.com Assigned to: thomas@fesch.at
Priority: high Milestone:
Component: script.aculo.us Version:
Severity: critical Keywords: dragdrop, Position, within, Droppable, includeScrollOffsets, fire, updateDrag, scroll
Cc: bpan@netcentrics.com

Description

The following defect was noticed from Script.Aculo.us versions 1.5.3 to 1.6.1.

I have a DIV container which has a set width and height. It is set to auto-scroll with "overflow: auto" style. It contains a bunch of Droppable elements (with onHover/onDrop events and some options parameters). I noticed that if I scroll the container to reveal a Droppable element at the bottom, when I drag a Draggable element to it, the code somehow thinks the Droppable element is a certain distance higher in the container. The vertical distance in error is the same as the scrolled distance. Therefore, when I drop the element, it goes to the wrong Droppable area in another location.

I have looked at dragdrop.js, particularly the Droppables.isAffected() and Droppables.show() methods. They are using prototype's Position.within() method to detect if the mouse event position is within any Droppable element's boundaries. However, by default, Position.within() method does not use its "includeScrollOffsets" boolean member. This boolean member is set to false by default and I couldn't find anywhere in the prototype.js that sets it to true.

My work-around for now is to find "Position.prepare();" string within dragdrop.js, and manually add "Position.includeScrollOffsets = true;" at the next line. This seems to have fixed the above issue. The three places I've updated are Droppables.fire(), Draggable.updateDrag(), and Draggable.scroll().

Of course, because of my limited knowledge of prototype and Script.Aculo.us, there may be much better solution to the issue. I'm looking forward to seeing this issue getting resolved in your later releases. Thanks!

Change History

06/23/06 04:48:53 changed by woranl@gmail.com

This problem only happen in IE6. It works fine in Firefox.

I've a droppable inside a DIV container, which is set to overflow:scroll. When I scroll the div container, the droppable stays in its original position. When I drag a dragable to the wrong positioned droppable, the droppable reset itself to the correct after-scrolled position.

I try to edit the dragdrop.js to include the "Position.includeScrollOffsets = true;" as mentioned in the previous post. But it doesn't seem to work.

This is a show-stopper for me. Any feedback to this problem is highly appreciated.

06/23/06 10:27:15 changed by madrobby

  • status changed from new to closed.
  • resolution set to invalid.
Position.includeScrollOffsets = true;

works perfectly fine here in likewise situations.

I suggest you put up an example of your problem at some URL and ask in the #prototype irc channel on freenode, or on the rails-spinoffs mailing list, that should be the quickest way to find the issue. Closing the ticket.