Scriptaculous 'Draggable' in scrolling container ignores Position.includeScrollOffsets=true ?

UPDATEThis only happens when “ghosting” is set to true on the draggable – unfortunately, I need ghosting to be enabled on what I am doing… I've been chasing a problem round for about a day now and am convinced there is a problem in the latest version of (v 1.82) – I've created a test page to demonstrate it. The situation is when you have Draggable(s) inside a scrolling container element.  The scrolling element is of fixed size, it has the CSS 'overflow' properly set to either 'scroll' or 'auto' and there are elements inside it marked as being draggable – for example.
new Draggable(myDraggableElement, {ghosting:true, revert:true, scroll:'main'});
'main' is the ID of the scrolling container element around the Draggable(s). As soon as you scroll down in the scrolling container and start to drag a draggable, the draggable is off-set from the mouse pointer by an ever-increasing distance, depending on how far down you've scrolled the scroll bar. Now then, this all works fine when using a Sortable instread of a Draggable but you have to remember to use…
Position.includeScrollOffsets = true;
…before creating the Sortable. So, my question is, why does this not work for a Draggable when it works fine in the same instance for a Sortable? On looking through the code in it appears tha the Draggable code does not indeed honour the Position.includeScrollOffsets booleam – why?  Is this an oversight on their part? I've tried asking in the #prototype IRC channel – no luck.  I've posted to the Prototype & Google Group and had no replies at all (why don't people reply to difficult questions and forums are only full of n00b questions?!).   On doing a good Google search the closest I can find is this bug report on Rails Trac :-

Draggable does not include scroll offset when dragging in a scrollable container
When setting the scroll property in a draggable, it does not set Position.includeScrollOffsets to true. So, although the draggable is drawn correctly and scrolling occurs as expected, droppables within the scrolling container are not activated correctly.
This bug report sounds exactly like the bug I'm seeing.  It was opened 2 years ago, updated 1 year ago and still not resolved…WTF ?    There are two patches posted though but neither of these seem to solve the problem for me. Back to digging around in the code I guess and try to work out how it's intended to work.  I'm still investigating but will update more as and when I find anything…

Leave a comment

Your email address will not be published. Required fields are marked *