Skip to content

Instantly share code, notes, and snippets.

@AMSTKO
Created September 15, 2011 12:50
Show Gist options
  • Select an option

  • Save AMSTKO/1219157 to your computer and use it in GitHub Desktop.

Select an option

Save AMSTKO/1219157 to your computer and use it in GitHub Desktop.
resize.js
var resize = {
anim: function (e,a,d,p,k){
var s=e.style,c=parseInt(s[a]),f=p+c;
e.resize={s:0};
(function u(){
c=(c+p/d*10);
s[a]=c+'px';
f!=~~c && e.resize.s==0 ?setTimeout(u,10): k?k.call(e):0;
})();
},
stop: function (e) {
if(typeof(e.resize)!='undefined') e.resize.s=1;
}
};
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="aza" style="width:100px; height:200px; background-color:#ff00ff;" ></div>
<script>
var resize = {
anim: function (e,a,d,p,k){
var s=e.style,c=parseInt(s[a]),f=p+c;
e.resize={s:0};
(function u(){
c=(c+p/d*10);
s[a]=c+'px';
f!=~~c && e.resize.s==0 ?setTimeout(u,10): k?k.call(e):0;
})();
},
stop: function (e) {
e.resize.s=1;
}
};
var e = document.getElementById('aza');
resize.anim(e, 'width', 20000, 1000, function () {
resize.anim(e, 'height', 20000, -100);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment