Hi there,

is it possible to maintain the elements order in DOM when using
Effect.Move()? Currently the Move effect will
change the element position (using top and left style attrs), this
works quite well too, but what I'd like is
to change the elements position as well.
Consider the following example:

html:
...
<div id="a">First</div>
<div id="b">Second</div>
...

JS:

// switch two divs positions using DOM
function switchPositionsWithDOM(first, second) {
    var parentElem = first.up();
    var secondId = second.id;
    var s = second.remove();
    parentElem.insertBefore(s, first);
}

// switch positions using Effect.Move
function switchPositionsWithMove(first, second) {
    var delta = Position.cumulativeOffset(first)[1] -
Position.cumulativeOffset(second)[1];
    new Effect.Fade(first, {from: 1.0, to: 0.3});
    new Effect.Fade(second, {from: 1.0, to: 0.3});
    new Effect.Move(second, {x: 0, y: delta});
    new Effect.Move(first, {x: 0, y: -delta});
    new Effect.Appear(second, {from: 0.3, to: 1.0});
    new Effect.Appear(first, {from: 0.3, to: 1.0});
}

after calling switchPositionsWithDOM($('a'), $('b')); I'll end up with
...
<div id="b">Second</div>
<div id="a">First</div>
...
However, switchPositionsWithMove($('a'), $('b')); will obviously
produce
...
<div id="a" style="top: xxx; left: xxx;">First</div>
<div id="b" style="top: xxx; left: xxx;">Second</div>
...

What I'd like to do is - create the nice visual effect as defined in
switchPositionsWithMove(), but
reorder the DOM structure as in switchPositionsWithDOM(). Ideas
anyone?

TIA,
jenner


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to