Loading ...
Sorry, an error occurred while loading the content.

2356Re: [ydn-javascript] research: why YUI dragdrop is so slow

Expand Messages
  • Peter Michaux
    Jun 16, 2006
    • 0 Attachment
      Hi Tim,

      On 6/16/06, Tim Hosking <tim@...> wrote:
      >
      > Oh. I thought I did. Anyway. The draggable items represent virtual
      > files retrieved from a mysql query. The user will (hopefully) be able
      > to select any number of these items and move them between lists.
      > Rather like moving files on your desktop. In a recent test I created
      > 1000 items in a list (OK, rendering that many items onto the browser
      > window could be considered DOM abuse :-) When they eventually
      > appeared, I was able to drag them smoothly in FireFox and Safari, but
      > the initial delay in the mousedown gave me tennis elbow. I am in the
      > early stages of writing a class to display the items in columns, thus
      > greatly reducing the number of items, displayed, but with my test
      > data I would still get over 200 items in one column.

      What I was trying to get at is why do you have to cache 1000 element
      locations and/or regions. You only need to cache the items you will
      drag and their possible targets. Could you somehow rework the problem
      so this is just a few things at the start of each drag?

      > I read you article about optimising dragging with the donut method,
      > and was impressed with it's speed, especially the light show effect
      > when you drag the target over the top edge of the lower of the two
      > grouped drop areas :-) (yes, I know it's because you offset the
      > location of those items when you highlight them). My code uses a
      > translucent clone of the dragged item as the proxy element, so I'm
      > not sure how we would go about punching a mouse hole in it.

      This would require creative CSS. I haven't tried this yet but maybe
      you could use the clipping and/or overflow control features of CSS.
      Put some of the things you want to clone in each of the four donut
      divs and then when the donut is assembled things would look normal
      with a one or more pixel hole in the middle. That is my idea anyway.

      > Correct me if I'm wrong, but I thought you were saying that with YUI
      > don't see mouseover events for the drop targets because the dragged
      > item is frontmost and always under the mouse. I checked this with
      > FireBug, and it does generate mouseover events for the correct items.
      > Am I missing something here?

      Maybe I'm missing something. I haven't ever used firebug. Here is an
      example that shows that the mouseover event does not fire while
      dragging an element under the cursor.

      http://peter.michaux.ca/examples/donut-dragdrop/event-test.html

      That example convinces me that the mouseover doesn't fire.


      > My problem is not with the performance of the drag, but the delay in
      > the mousedown handler at the start of the drag. The refreshCache()
      > function traverses the DOM tree many times looking for draggable
      > elements.

      The dragdrop library always holds the id's of all draggable elements.
      refreshCache should not have to look for these items.

      refreshCache calls getLocation which calls getEl. If you haven't
      called getEl for each draggable yet then maybe that is taking some
      time: all the document.getElementById() calls. You could do this after
      each draggable instance is created. As part of your Draggable subclass
      constructor. I think Draggable's constructor should do this anyway.
      Probably the getXY call in getLocation is the really slow problem. If
      you know the geography of your list items (height etc) perhaps you
      could do getXY for the first element and then just increment these
      values for the others in the list.


      Peter
    • Show all 15 messages in this topic