Displaying 1 result from an estimated 1 matches for "switchpositionswithmove".
2007 Jul 31
6
Using Effect.Move() while maintaining the elements DOM order
...t;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: -delt...