javascript - JqueryUI Animation from one button to another -
i'm trying create function use later, animate button1 twords button2, make button1 same size button2 , bring button1 original position , size.
i managed return button1 original position, can't figure out size part, keeps making button smaller , smaller, please see jfiddle below, think it's not counting padding, , i'm not sure how.
can help?
function movefromto(fromid, toid, relative) { var fromshape = $("#" + fromid); var toshape = $("#" + toid); var fromposition; var toposition; if (relative === true) { fromposition = fromshape.offset(); toposition = toshape.offset(); } else { fromposition = fromshape.position(); toposition = toshape.position(); } console.log(fromshape); console.log("width " + fromshape.width() + "px" + ", height " + fromshape.height() + "px"); console.log(toshape); console.log("width " + toshape.width() + "px" + ", height " + toshape.height() + "px"); var initproperties = { top: 0, left: 0, width: fromshape.width() + "px", height: fromshape.height() + "px" }; var properties = { top: (toposition.top - fromposition.top) + "px", left: (toposition.left - fromposition.left) + "px", width: toshape.width() * 1.2 + "px", height: toshape.height() * 1.2 + "px" }; console.log(toshape.width() * 1.2 + "px"); console.log(toshape.height() * 1.2 + "px"); fromshape .animate(properties, 1000, function() { toshape.toggle("explode", { pieces: 100 }, 500); }) .animate(initproperties, 200, function() { toshape.toggle("explode", { pieces: 100 }, 100); }); };
Comments
Post a Comment