to increase the speed control the increment, to decrease control the time interval or just use fraction increments and cast them to integer value.
here is the code modification on your code:
var speed = 2.0;
targetExpanded.addEventListener('click', function(e) {
e.preventDefault();
var $this = this;
function slideDown() {
$this.style.height = minHeight + 'px';
minHeight+=speed;
if (minHeight >= realHeight) {
$this.style.height = realHeight + 'px';
clearInterval(slideDownTimer);
}
}
function slideUp() {
$this.style.height = minHeight + 'px';
minHeight-=speed;
if (minHeight <= 58.0 ) {
$this.style.height = 58.0 + 'px';
clearInterval(slideUpTimer);
}
}
if (minHeight < realHeight) {
slideDownTimer = setInterval(slideDown, 1);
} else if (minHeight == realHeight) {
slideUpTimer = setInterval(slideUp, 1);
}
});
here is the fiddle DEMO
fiddle modified to work with slower or faster (slower = fractions of 1 e.g. 0.2) just using floating points instead of integers, and they will be cast automatically to int as a pixel cannot be divided.
you can pass the speed to the function as a parameter to make it safer. this is merely a demonstration of the idea.