I am trying to make a jquery plugin to animate an element to take over another ... take this for example
I want to make the animation to carry the Phone div as is and make it in the position and dimension of c1, the div that is highlighted ...
So i ended up making this code which partially worked :
$.fn.expandTo = function (targetId) {
targetId = $(targetId);
var mView = $(this);
log('POSITION');
log(mView.position());
log('OFFSET');
log(mView.offset());
if(mView.position() === undefined) mView = mView.parent();
mView.animate({
position : 'absolute',
height : targetId.height(),
width : targetId.width(),
top : targetId.position().top,
left : targetId.position().left
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
it worked for the first purpose , moving the phone div to that at the bottom , however reversing that animation couldn't successfully happen ... Please any help is appreciated and I can give any additional needed info