0

I am trying to create a function that lets me move elements around with a timing effect. Here I am using the .insertBefore and .insertAfter with 2 buttons to move DIV's up and down. I would like to know if it is possible to use the .animate effect here to set a timing effect while the DIV's move from one place to another.

Cheers

function moveup(mover){
           if($(mover).parent().prev().is('div'))
             $(mover).parent().insertBefore($(mover).parent().prev());
        }

function movedown(mover){
   if($(mover).parent().next().is('div'))
     $(mover).parent().insertAfter($(mover).parent().next());
}
Adrien Boufflet
  • 141
  • 1
  • 10
  • 1
    Why are you using `insertBefore` and `insertAfter` at all? Is there some content in the `mover` element that you need duplicated? If you're just moving the elements up and down, you should modify their `top` position, or maybe ``margin-top`, but not be inserting extra elements. – DACrosby Feb 28 '15 at 19:16
  • Yes these are cloned elements. cloning a div after a div. I would need that on the moveup and movedown functions, we see the divs move from one position to another. right now they are moving instantly. – Adrien Boufflet Feb 28 '15 at 19:42
  • Okay, then you want something like this: http://stackoverflow.com/questions/17020758/add-sliding-animation-to-jquery-insertafter-and-insertbefore – DACrosby Feb 28 '15 at 20:13
  • Thanks. I think this is going to be a little more work than I thought ;-). I will need to get the other divs position that I am replacing first to be able to take its position. seeing these divs are being cloned this might be a little complicated;-) – Adrien Boufflet Feb 28 '15 at 20:47

0 Answers0