I create an extended admin panel and I play the role of editing elements, I like it when I click to edit an element that it would fill with all the space of its parent, however I do not know how to make the element return to its original position with animation, any idea , how to do it? I have tried this so far:
Here is the pen: http://codepen.io/anon/pen/WvGONp
HTML
<div id="container"> <div class="single-item"> <div class="title">home</div> <a class="edit" href="#"></a> </div> <div class="single-item"> <div class="title">Gallery</div> <a class="edit" href="#"></a> </div> <div class="single-item"> <div class="title">Contact</div> <a class="edit" href="#"></a> </div> </div>
SCSS
* { margin: 0; padding: 0; border: 0; box-sizing: border-box; } html, body,
Javascript
$("#container").on("click", ".edit", function(e){ e.preventDefault(); var el = $(this); var elParent = el.closest(".single-item"); var curElTop = elParent.position().top; var curElLeft = elParent.position().left; elParent.toggleClass("active", function(){ elParent.css({ position: "absolute", top: curElTop, left: curElLeft }).animate({ top: 0, right: 0, bottom: 0, left: 0 }); }); });
source share