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

Re: [ydn-javascript] Re: Cancelling a drag-and-drop

Expand Messages
  • Adam Platti
    yea, it would be cool if there was an API for aborting a drag from inside b4Drag. Adam
    Message 1 of 6 , May 31, 2007
    • 0 Attachment
      yea, it would be cool if there was an API for aborting a drag from inside b4Drag.

      Adam

      On 5/30/07, Dave <doyle@... > wrote:

      I had already tried this and it 'almost' worked. Unfortunately the
      proxy still traveled around until it was released, giving the
      impression that it was still droppable. To get this far I locked it
      on startDrag and then checked if it was locked on stopDrag and
      unlocked it if it was.

      But I think I've found a solution that avoids moving the proxy at all.
      As mentioned by Adam earlier, I overrode the b4drag method, and after
      identifying that the user was attempting to drag the last element in a
      list, called DDM.handleMouseUp(e).

      This did what I wanted, but uncovered a bug in the Yahoo codebase.
      For anyone else that wants to do this, you'll need to change line 677
      in the dragdrop.js from:
      this.dragCurrent.onDrag(e);
      to:
      if (this.dragCurrent) this.dragCurrent.onDrag(e);

      Dave

      --- In ydn-javascript@yahoogroups.com, "someguynameddylan"


      <DylanTheDeveloper@...> wrote:
      >
      > Hi,
      >
      > I've faced an issue like that before, if you don't want the last item
      > to be dragged, then you can call the instance method
      > YAHOO.util.DragDrop.lock() for the DD object that is representing that
      > last element.
      >
      > But then of course you won't be able to drop anything on it. If
      > dropping on the item is also desired then you'll have to provide some
      > logic to single out the last element in the list and instantiate a
      > DDTarget object instead of the regular DD or DDProxy object for it.
      >
      > Hope that helps,
      >
      > Dylan
      >
      > --- In ydn-javascript@yahoogroups.com, "Dave" <doyle@> wrote:
      > >
      > > Hi everyone,
      > >
      > > I've read through the archive, but I cannot find the answer to my
      > > question. I've created a drag/drop app using proxies objects that is
      > > almost exactly like the sortable list example
      > >
      (http://developer.yahoo.com/yui/examples/dragdrop/list.html?mode=dist ).
      > > However, the one difference is that the last item in one of the lists
      > > (no matter which one) cannot be dragged out of the list. Is there a
      > > way to cancel an attempt to drag if the user drags the last element
      > > from a list?
      > >
      > > What I've been trying to do is place the code in the startDrag method
      > > and have been able to identify an attempt to drag the last element as:
      > >
      > > if (!mycontainer.firstChild.nextSibling && this.getEl() ==
      > > mycontainer.firstChild) {
      > > }
      > >
      > > But what do I put in this to completely cancel this specific attempt
      > > at dragging?
      > >
      >


    Your message has been successfully submitted and would be delivered to recipients shortly.