а если так)
модифицировал свою старую анимацию, printIn - печать , printOut -удаление.
<!DOCTYPE HTML>
<html>
<head> </head>
<body>
<div id="t"><p>asdsadasdsa</p> asdsadsadsad<div>asdasdas1</div></div>
<script>
var Text = {
printIn:function (elem,str,duration,callback){
var i = 0, string = "", self = this;
(function start(){
if(i > str.length-1 ) {
if(callback)callback();
return;
}
var tag = self.Tags(str,i);
if(tag == null) string += str[i];
else {
string+= tag.tag;
i = tag.position;
}
elem.innerHTML = string;
i++;
setTimeout(arguments.callee,duration);
}());
},
printOut:function (elem,str,duration, callback){
var i = str.length, string="", self = this;
(function(){
if(i < 0 ){
if(callback)callback();
return;
}
var tag = self.Tags(str,i);
if(tag != null) i = tag.position;
elem.innerHTML = str.slice(0,i);
i--;
setTimeout(arguments.callee,duration);
}());
},
Tags: function(text, num){
var symb = text[num];
var start, end, val = {}, open, close;
if(symb == '<'){
open = text.indexOf("<",num);
start = num;
end = text.indexOf(">",num);
if(open < start) return null;
val.tag = text.slice(start, end+1);
val.position = end;
}
else if(symb == '>'){
close = text.lastIndexOf(">",num);
end = text.lastIndexOf("<",num);
if(end > close ) return null;
val.position = end;
}
else return null;
return val;
}
};
var el = document.getElementById("t");
Text.printIn(el, el.innerHTML,50,callback);
function callback(){
Text.printOut(el, el.innerHTML,50);
}
</script>
</body>
</html>