Deprecated: Function set_magic_quotes_runtime() is deprecated in /home4/mfoster/public_html/cb/forums/include/common.php on line 62

Warning: Cannot modify header information - headers already sent by (output started at /home4/mfoster/public_html/cb/forums/include/common.php:62) in /home4/mfoster/public_html/cb/forums/header.php on line 31

Warning: Cannot modify header information - headers already sent by (output started at /home4/mfoster/public_html/cb/forums/include/common.php:62) in /home4/mfoster/public_html/cb/forums/header.php on line 32

Warning: Cannot modify header information - headers already sent by (output started at /home4/mfoster/public_html/cb/forums/include/common.php:62) in /home4/mfoster/public_html/cb/forums/header.php on line 33

Warning: Cannot modify header information - headers already sent by (output started at /home4/mfoster/public_html/cb/forums/include/common.php:62) in /home4/mfoster/public_html/cb/forums/header.php on line 34
Cross-Browser.com / Adding xEnableDrag functionality to a parent div from a child

Cross-Browser.com

X Library Forums

You are not logged in.

Announcement

New user registration is currently disabled.

#1 December 22, 2009 11:04:51 am

DaveMorton
Member
From: Carson City, NV
Registered: November 27, 2009
Posts: 49
Website

Adding xEnableDrag functionality to a parent div from a child

I'm having a bit of difficulty with the PM window in pChat, where you can't use the text box with dragging is enabled on the parent div, so what I'd like to do is have the entire PM div drag-able only when the mouse is clicked on the header. Here's the HTML structure of the PM "window":

<!-- PM Window Start -->
    <div id="pmWindow" onclick="bringToFront(this)">
      <div id="pmHeader">
        Private Message
      </div>
      <div id="pmContent">PM Content</div>
      <div id="pmFooter">
        <input name="pmText" id="pmText" type="text" size="35" value="test"/>&nbsp;
        <input type="button" name="pmSubmit" id="pmSubmit" value="Send PM" onclick="sendPM()"/>
      </div>
      <div class="closeButton" onclick="hideMe(this); return false"></div>
    </div>
<!-- PM Window End -->



Right now, the dragging is enabled with the following line:

    xEnableDrag('pmWindow', null,null,null);



Of course, as expected, if I change the JS call to "pmHeader", it only drags the header around, which is not the desired outcome. smile

What's the best way to have the drag event affect the parent, rather than the child?

Or would it be better to migrate to using xFenster, instead?

Last edited by DaveMorton (December 22, 2009 11:06:30 am)


Safe, Reliable Insanity, since 1961!
http://www.geekcavecreations.com

Offline

 

#2 December 22, 2009 11:08:48 am

DaveMorton
Member
From: Carson City, NV
Registered: November 27, 2009
Posts: 49
Website

Re: Adding xEnableDrag functionality to a parent div from a child

By the way, I believe that the fix for this will help with the scrolling issue that I have with the emotes window, as well, so I'll probably apply whatever fix to several of the popup divs, if not all of them.

Last edited by DaveMorton (December 22, 2009 11:09:15 am)


Safe, Reliable Insanity, since 1961!
http://www.geekcavecreations.com

Offline

 

#3 December 22, 2009 11:47:52 am

DaveMorton
Member
From: Carson City, NV
Registered: November 27, 2009
Posts: 49
Website

Re: Adding xEnableDrag functionality to a parent div from a child

Well, that was simpler than I had expected. big_smile Found the solution. I just created a function called dragParent, which uses xParent, and then I just applied the xMoveTo to the parent, rather than the child, and added the callback to the xEnableDrag call, like so:

  function dragParent(el, dx, dy, ev) {
    var ep = xParent(el);
    xMoveTo(ep, ep.offsetLeft + dx, ep.offsetTop + dy);
  }

...

    xEnableDrag('pmHeader', null,dragParent,null);



This takes care of not only the PM window's problem, but also the emotes and debug windows, as well. smile

[edit]I should have the changes uploaded within the hour. Thanks again, Mike! I LOVE x! [/edit]

Last edited by DaveMorton (December 22, 2009 11:49:38 am)


Safe, Reliable Insanity, since 1961!
http://www.geekcavecreations.com

Offline

 

#4 December 23, 2009 11:01:10 am

MikeFoster
Administrator
From: Alabama, USA
Registered: April 27, 2007
Posts: 874
Website

Re: Adding xEnableDrag functionality to a parent div from a child

Sorry for the late reply. Awesome work! smile

Offline

 

Board footer

Powered by PunBB 1.2.15
Copyright © 2002–2005 Rickard Andersson

Expand Restore Select Format Eval Load