Created
August 1, 2013 19:14
-
-
Save SauloSilva/6134306 to your computer and use it in GitHub Desktop.
Resize, element html, pure javascript.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var object = undefined | |
, minimum = undefined | |
, count = 0 | |
, limit = 0 | |
, skip = 5 | |
, interval = undefined; | |
function expand(width) { | |
object = document.getElementById('super'); | |
minimum = object.offsetWidth; | |
limit = width; | |
stop(); | |
interval = setInterval('toggle()', 0.1); | |
if (count == 0 ) { count += minimum }; | |
} | |
function toggle() { | |
if (limit > minimum){ | |
increment() | |
} else{ | |
decrement() | |
} | |
document.getElementById('super_expand').style.width = count + "px"; | |
object.style.width = count + "px"; | |
} | |
function increment(){ | |
if (limit > count){ | |
count += skip; | |
} else{ | |
stop(); | |
} | |
} | |
function decrement(){ | |
if (limit < count){ | |
count -= skip; | |
} else{ | |
stop(); | |
} | |
} | |
function stop() { | |
clearInterval(interval); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment