Page 1 of 1

drag and drop functionality with FF

Posted: Thu Sep 14, 2006 12:17 pm
by Burrito
Since I've made the 100% switch to FF from IE 4.5 months ago, I've been a happy man...that is until yesterday. I am having a helluva time getting FF to act even remotely normally on some drag and drop stuff I'm writing. The site is written strictly css which is what is causing the problem. When I drag an element, FF actually repositions some of my other divs (apparently it thinks that's a cool thing to do despite my disagreement), selects text that I'm dragging over (while dragging), and a few other really quirky things (like occasionally putting the dragged element about 200 pixels below my cursor).

This works perfectly in IE. I'm using a completely different function set for IE than I am for FF but that has nothing to do with this particular issue (I'm just using different functions to figure out which object is being dragged (event.target vs event.srcElement)).

I don't have the time to rework the entire thing using tables (for a comparative test), but I can say with 97.24% certainty that it would work fine with tables (based on some past drag and drop stuff I've done using tables).

I could move to a library like scriptaculous, but those of you who know me, know I like to write all my own shizzle and that goes against the grain for me and I'd like to avoid that at all costs.

so my question....finally: do any of you have any experience doing drag and drop stuff with FF using css for your layout? If so, did you experience any of the hurdles I mentioned, if so, were you able to jump them? I can't really show an example unfortunately because I'd be violating something...not exactly sure what, but something for sure. If it becomes necessary, I'll make something up for you to see an example.

Posted: Thu Sep 14, 2006 2:48 pm
by Luke
Have you looked through scriptaculous's source code (or similar libs) to see how they did it?

Posted: Thu Sep 14, 2006 4:09 pm
by ok

Posted: Thu Sep 14, 2006 4:12 pm
by Burrito
The Ninja Space Goat wrote:Have you looked through scriptaculous's source code (or similar libs) to see how they did it?
yeah but it's not for the feint of heart...really sophisticated stuff going on there. It pretty much kicked my ass thrice then said 'don't come back here ever again'...so I haven't.

Posted: Thu Sep 14, 2006 4:13 pm
by Luke
Burrito wrote:
The Ninja Space Goat wrote:Have you looked through scriptaculous's source code (or similar libs) to see how they did it?
yeah but it's not for the feint of heart...really sophisticated stuff going on there. It pretty much kicked my ass thrice then said 'don't come back here ever again'...so I haven't.
haha :lol: that was great... well alright then.

Posted: Thu Sep 14, 2006 11:59 pm
by Burrito
I got this figured.

here's what was happening:

firstly: I was using document.onmousedown = myfunction; and that was causing my divs to be moved, changed etc...basically just crap that I didn't want.
secondly: I used a style property to disable selection on the page (-moz-user-select: none;)...this fixed the selection of stuff that I didn't want while dragging
thirdly: I had an onmousemove event that was being called on some of my text, that was borking up my dragging when it'd mouse over sometimes, so I set a dragging flag and if it's on, don't do the mousemove event, if it's off, go nuts.

whew! I need to do something to celebrate this.