Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #3482 (new defect)

Opened 2 years ago

Last modified 2 years ago

Draggable element positioning get's corrupted when using Element.show/Element.hide

Reported by: smcallis@gmail.com Assigned to: thomas@fesch.at
Priority: normal Milestone:
Component: script.aculo.us Version:
Severity: normal Keywords:
Cc:

Description

I've got a simple div which I use to display some data on my page. It goes something like this:

<div class="entryDiv" id="entryDiv" style="display: none"> </div>

<%= draggable_element "entryDiv", :revert => null %>

Now, I have a list of contacts that use an ajax updater to dump the data for a contact into the div, and then call Element.show('entryDiv'). In the entry div, I have a target that calls Element.hide('entryDiv'), to "close" the display. Now, when I load the page and click on a contact, it works fine, loads the data and shows up, is draggable, works just like I wanted it to. I can click on other contacts and see the ajax is working fine, it replaces the data. However, when I close the div and re-open it, the positioning of it get's corrupted, it often shows up far down the page, far to the right. If I was better with javascript, I'd try to find the bug myself, but alas I'm not =(

Change History

01/21/06 00:13:45 changed by madrobby

  • priority changed from high to normal.
  • severity changed from major to normal.

Please provide a testcase for this (preferably at an online URL, or as an HTML attachment).

02/16/06 19:59:49 changed by gkupps@yahoo.com

I think I'm experiencing something simmilar. Here is a ticket i created and i've attached a sample as well http://dev.rubyonrails.org/ticket/3860

04/27/06 17:22:25 changed by anonymous

I'm experiencing similar problems with a tabbed bar that contains draggables. The inactive parts are with display:none. The draggables they contain revert to a wrong position (0,0) in Firefox. My workaround was to recalculate the delta when I change the status of the tabbed bar (i.e. set display:block of the div with the draggables again).

I did something like this:

var myDraggables = {
  draggable_1: new Draggable('dom_id', {revert: true}),
  draggable_2: new Draggable('other_dom_id', {revert: true})
}

function refreshDeltas() {
    for(var d in myDraggables) {
        myDraggables[d].draggable.delta = myDraggables[d].draggable.currentDelta();
    }
}

function changeTabbar(changeTo) {
   $(oldThingy).style.display = 'none';
   $(changeTo).style.display = 'block';
   refreshDeltas();  
}

HTH

04/27/06 17:41:18 changed by anonymous

Ok, here's a quick patch for the current trunk (in function "initDrag"):

280 + this.delta  = this.currentDelta();

Hoping this won't break anything else