Oops... attacfhed

On 6/14/07, Gareth Evans <[EMAIL PROTECTED]> wrote:
>
> Okay, so a bit more digging around... something appears to be weird with
> the offset calcuations.
> From my observations, the onHover handler and the onEmptyHover handler get
> fired.
> They both calculate where to insert an item, and one of them calculates it
> differently to the other.
> This results in the 'jitterbug' i've referred to.
> The patch earlier described (and documented on trac, but its actually a
> patch for some other tree functionality) shows a if (child == null)
> conditional around the final 'insert' statements.
> Because of this, I *think* that the for loop that appears above this if is
> not actually required and it's sufficent to just check children.length ==
> 0.
> Meaning, if there are no children elements then we want the onEmptyHover
> to insert the element.
> I'm not very familiar with the intricacies of Sortable, other than what
> i've played with to get this working, but when I check children.length ==
> 0 instead of having the for loop using offsets to identify if where the item
> should go, the 'jitter' effect goes away for me.
> As previously mentioned, both onHover and onEmptyHover fire when i'm doing
> a drag with dropOnEmpty:true.
>
> I'm trying to figure out what i've broken by removing the offset
> calculation, and if it's going to be an issue for anything else I might do
> with Sortable later in my developments.
>
> Could one of the scripty gods read this thread and advise?
>
> I'll attach a shortened version of my new dropOnEmpty code, which has some
> other modifications to allow a 'marker' element, from Tankut Koray, and
> myself to make his code conditional.
> I haven't touched made any modifications to scripty base dragdrop.jsfunctions 
> other than onEmptyHover but
> unMark, onHover have been changed by Tankut, and markEmptyPlace and
> createGuide have been created by him. I've since added if statements before
> his code to read an options setting so I can turn his functionality off (I
> only need it on one page)
>
> This issue has been driving me mad for weeks so it'd be good to get this
> stuff sorted.
>
> http://dev.rubyonrails.org/ticket/7807
> This patch is similar but doesn't quite fix the functionality in my app...
> for some reason.
> (It adds the if (child==null) which worked for junkmate's app, but didn't
> work for mine, I had to go to the children.length == 0)
>
> Gareth
>
>  On 6/13/07, Gareth Evans <[EMAIL PROTECTED]> wrote:
> >
> > Yeah, the demo is working but the fix *will not* work in my
> > application...
> > There must be more at play here...
> >
> > Gareth
> >
> >
> >  On 6/13/07, junkmate <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > > your demo looks good to me mate! Hopefully that should solve our
> > > problems eh!
> > >
> > > right one job done, time for bed!
> > > Will check again in the morning to see how you got on.
> > >
> > >
> > >
> > > On Jun 13, 2:42 am, "Gareth Evans" < [EMAIL PROTECTED]> wrote:
> > > > Odd.. grabbed beta3, overwrote, added the if statement... all fixed.
> > >
> > > > I'll try in my actual application now.
> > > >
> > > > Gareth
> > > >
> > > > On 6/13/07, Gareth Evans < [EMAIL PROTECTED]> wrote:
> > > >
> > > >
> > > >
> > > > > Hey man
> > > >
> > > > > That was a good idea, I guess it fixed your prob but it doesnt
> > > seem to
> > > > > have fixed mine
> > > >
> > > > > Check it out
> > > > >http://202.49.89.140/SortableExample.html
> > > >
> > > > > There's a if (child==null) { } around the 3 lines you suggested.
> > > >
> > > > > I'll try applying the aforementioned patch.
> > > >
> > > > > Gareth
> > > >
> > > > >  On 6/13/07, junkmate < [EMAIL PROTECTED]> wrote:
> > > >
> > > > > > in fact, you dont need to do all that. The answer relates
> > > EXACTLY to
> > > > > > what you said my man, with the two things fighting each other...
> > >
> > > > > > The only thing you need to add is some if child==null brackets
> > > around
> > > > > > the end of the onEmptyHover function:
> > > >
> > > > > >        dropon.insertBefore(element, child);
> > > > > >         Sortable.options(oldParentNode).onChange(element);
> > > > > >        droponOptions.onChange(element);
> > > >
> > > > > > CHANGE ABOVE TO BELOW:
> > > >
> > > > > > if (child == null) {
> > > > > >         dropon.insertBefore(element, child);
> > > > > >        Sortable.options(oldParentNode).onChange(element);
> > > > > >        droponOptions.onChange (element);
> > > > > > }
> > > >
> > > > > > On Jun 13, 1:49 am, junkmate < [EMAIL PROTECTED] > wrote:
> > > > > > > FIXED:http://groups.google.com/group/rubyonrails-spinoffs/browse_thread/thr
> > > .
> > > > > > ..
> > > >
> > > > > > > Make the few suggested changes there and all works fine for
> > > me!
> > > >
> > > > > > > On Jun 13, 1:29 am, junkmate < [EMAIL PROTECTED]> wrote:
> > > >
> > > > > > > > hmmm. definately does.
> > > >
> > > > > > > > its annoying as every time i think ive fixed it by getting
> > > the
> > > > > > > > flickering to stop, it turns out that my modifications have
> > > simlply
> > > > > > > > disabled the dropOnEmpty functionality of the function :(
> > > Will keep
> > > > > > > > plodding on till I get there! Keep up the good work.
> > > >
> > > > > > > > On Jun 13, 1:20 am, "Gareth Evans" < [EMAIL PROTECTED]>
> > > wrote:
> > > >
> > > > > > > > > And a bit of evidence
> > > > > > > > > I added insertions to the onEmptyHover and onHover
> > > internal
> > > > > > functions to
> > > > > > > > > identify when they were being called.
> > > > > > > > > I assigned an 'index' attribute to every item in the
> > > dom...
> > > > > > > > > Then found all the insertBefore's and got it to spit out
> > > the
> > > > > > index... this
> > > > > > > > > is the output
> > > >
> > > > > > > > > onEmptyHover Insertion @ 8
> > > > > > > > > onHover
> > > > > > > > > onHover
> > > > > > > > > onHover
> > > > > > > > > onHover
> > > > > > > > > onHover
> > > > > > > > > onHover Insertion @ 7
> > > > > > > > > onEmptyHover
> > > > > > > > > onEmptyHover Insertion @ 8
> > > > > > > > > onHover
> > > > > > > > > onHover Insertion @ 7
> > > > > > > > > onEmptyHover
> > > > > > > > > onEmptyHover Insertion @ 7
> > > >
> > > > > > > > > Looks like this is on the right track, agree?
> > > >
> > > > > > > > > Gareth
> > > >
> > > > > > > > > On 6/13/07, Gareth Evans < [EMAIL PROTECTED]> wrote:
> > > >
> > > > > > > > > > As far as I can tell,
> > > > > > > > > > In Create, it does some stuff that when dropOnEmpty is
> > > true, it
> > > > > > uses
> > > > > > > > > > options_for_tree to create a droppable.
> > > > > > > > > > This defines the onHover handler to be onEmptyHover.
> > > > > > > > > > The default onHover handler is just onHover.
> > > >
> > > > > > > > > > Oohh here's something interesting.
> > > >
> > > > > > > > > > I added an insertion for debug to both onHover and
> > > onEmptyHover
> > > > > > and *both*
> > > > > > > > > > are firing when it jitters.
> > > >
> > > > > > > > > > If one was calculating the location to be above, and the
> > > other
> > > > > > below,
> > > > > > > > > > under a certain condition- wouldn't this cause the
> > > effect we
> > > > > > saw, as they'd
> > > > > > > > > > fire sequentially, one would move it up, the other would
> > > move it
> > > > > > down...
> > > >
> > > > > > > > > > Gareth
> > > >
> > > > > > > > > > On 6/13/07, junkmate <[EMAIL PROTECTED]> wrote:
> > > >
> > > > > > > > > > > yup I tracked it down to there too. I cant find the
> > > "onHover
> > > > > > function
> > > > > > > > > > > when dropOnEmpty" is false though, so im unable to
> > > compare.
> > > >
> > > > > > > > > > > ps. I find it interesting that this demo works
> > > completely
> > > > > > fine:
> > > >
> > > > > >http://wiki.script.aculo.us/scriptaculous/page/print/SortableFloatsDemo
> > >
> > > >
> > > > > > > > > > > On Jun 13, 12:05 am, "Gareth Evans" < [EMAIL PROTECTED]
> > > > wrote:
> > > > > > > > > > > > Yeah looks like the same bug to me, though much more
> > > > > > accentuated on
> > > > > > > > > > > yours.
> > > > > > > > > > > > In dragdrop.js these lines appear to be responsible
> > > >
> > > > > > > > > > > > You can see i've added some debug insertions.
> > > > > > > > > > > > What appears to happen is that as i move the item
> > > up, one
> > > > > > pixel at at
> > > > > > > > > > > time,
> > > > > > > > > > > > it sometimes goes into the top branch, and
> > > occasionally into
> > > > > > the
> > > > > > > > > > > middle
> > > > > > > > > > > > branch.
> > > >
> > > > > > > > > > > > This code reads *completely* differently to the
> > > onHover
> > > > > > function used
> > > > > > > > > > > when
> > > > > > > > > > > > dropOnEmpty:false.
> > > >
> > > > > > > > > > > >       if(children) {
> > > > > > > > > > > >         var offset = Element.offsetSize (dropon,
> > > > > > droponOptions.overlap)
> > > > > > > > > > > * (
> > > > > > > > > > > > 1.0 - overlap);
> > > >
> > > > > > > > > > > >         for (index = 0; index < children.length;
> > > index += 1)
> > > > > > {
> > > > > > > > > > > >           if (offset - 
> > > > > > > > > > > > Element.offsetSize(children[index],
> > > > > > > > > > > > droponOptions.overlap ) >= 0) {
> > > > > > > > > > > >             offset -= 
> > > > > > > > > > > > Element.offsetSize(children[index],
> > > > > > > > > > > > droponOptions.overlap);
> > > > > > > > > > > >      new Insertion.Top('debug','topbranch<br/>')
> > > > > > > > > > > >           } else if (offset - ( Element.offsetSize
> > > (children[index],
> > > > > > > > > > > > droponOptions.overlap) / 2) >= 0) {
> > > > > > > > > > > >             child = index + 1 < children.length ?
> > > > > > children[index + 1]
> > > > > > > > > > > :
> > > > > > > > > > > > null;
> > > > > > > > > > > >      new Insertion.Top('debug','midbranch<br/>')
> > > > > > > > > > > >             break;
> > > > > > > > > > > >           } else {
> > > > > > > > > > > >             child = children[index];
> > > > > > > > > > > >      new Insertion.Top ('debug','bottombranch<br/>')
> > > > > > > > > > > >             break;
> > > > > > > > > > > >           }
> > > > > > > > > > > >         }
> > > > > > > > > > > >       }
> > > >
> > > > > > > > > > > > I confess i'm not even sure what it's doing... at
> > > this
> > > > > > point.
> > > >
> > > > > > > > > > > > Gareth
> > > >
> > > > > > > > > > > > On 6/13/07, junkmate < [EMAIL PROTECTED]> wrote:
> > > >
> > > > > > > > > > > > > Heres my test page: 
> > > > > > > > > > > > > http://www.oldsushi.com/testing.php
> > >
> > > >
> > > > > > > > > > > > > Going there make your browser small enough so the
> > > images
> > > > > > are on two
> > > > > > > > > > > > > lines, and you will see the problem when dragging
> > > around
> > > > > > the second
> > > > > > > > > > > > > line and below.
> > > >
> > > > > > > > > > > > > On Jun 12, 11:10 pm, "Gareth Evans" <
> > > [EMAIL PROTECTED] >
> > > > > > wrote:
> > > > > > > > > > > > > > My problem, while related to dropOnEmpty as well
> > > seems
> > > > > > to only
> > > > > > > > > > > occur
> > > > > > > > > > > > > when my
> > > > > > > > > > > > > > sortables are nested, which is why I can't
> > > replicate it
> > > > > > on my test
> > > > > > > > > > > page.
> > > > > > > > > > > > > > I've been meaning to update my test page to
> > > prove it so
> > > > > > I have a
> > > > > > > > > > > clean
> > > > > > > > > > > > > page
> > > > > > > > > > > > > > to debug from within, that I can post up (it's
> > > really
> > > > > > hard to post
> > > > > > > > > > > up an
> > > > > > > > > > > > > > internal [read:burried] page of a web
> > > application.
> > > > > > > > > > > > > > I think there might be issues in the dropOnEmpty
> > > code.
> > > >
> > > > > > > > > > > > > > Perhaps we should team up to debug the solution
> > > at some
> > > > > > point,
> > > > > > > > > > > > > > What Instant Messaging tools do you use?
> > > >
> > > > > > > > > > > > > > On 6/13/07, junkmate < [EMAIL PROTECTED]>
> > > wrote:
> > > >
> > > > > > > > > > > > > > > any update on this? I am having exactly the
> > > same
> > > > > > problem.
> > > >
> > > > > > > > > > > > > > > I have two Div containers, one on top of the
> > > other,
> > > > > > where you
> > > > > > > > > > > can drag
> > > > > > > > > > > > > > > from on to the other.
> > > > > > > > > > > > > > > Each div is large enough for 5 images to fit
> > > on one
> > > > > > line.
> > > >
> > > > > > > > > > > > > > > With less than 5 images, dragging and dropping
> > > is a
> > > > > > pleasure,
> > > > > > > > > > > with
> > > > > > > > > > > > > > > everything looking great. However above 5
> > > images in
> > > > > > one
> > > > > > > > > > > container
> > > > > > > > > > > > > > > forces the images on to two rows, and then
> > > dragging
> > > > > > problems
> > > > > > > > > > > start.
> > > > > > > > > > > > > > > The top row is still perfectly fine, but the
> > > second
> > > > > > row and
> > > > > > > > > > > below it
> > > > > > > > > > > > > > > is very difficult to drag your image where you
> > > want it
> > > > > > to land,
> > > > > > > > > > > due to
> > > > > > > > > > > > > > > constantly alternating drop positions every
> > > pixel you
> > > > > > move...
> > > >
> > > > > > > > > > > > > > > This problem only occurs with dropOnEmpty set
> > > to true,
> > > > > > yet I
> > > > > > > > > > > must have
> > > > > > > > > > > > > > > the ability to empty these lists.
> > > >
> > > > > > > > > > > > > > > help :D
> > >
> > >
> > > > > >
> > >
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Attachment: dragdrop.changed.js
Description: JavaScript source

Reply via email to