Here is the plugin code:
Code:
function textTyping_animation(text,location,speed){
var progress = 0;
var a = setInterval(function(){
progress++;
document.getElementById(location).innerHTML = text.substring(0,progress);
if(progress == text.length){
clearInterval(a);
}
},speed);
};
(function($){
$.fn.textAnim = function(text,speed){
var progress = 0;
var a = setInterval(function(){
progress++;
$(this).html(text.substring(0,progress));
if(progress == text.length){
clearInterval(a);
}
},speed);
};
})(jQuery);
Here is the execution:
Code:
$(document).ready(function(){
starttext = function()
{
document.getElementById("textbox").style.display = "block";
//textTyping_animation("Dit is een dummy text!","textbox_inner",70);
//game.output("klaar");
$("#textbox_inner").textAnim("Dit is een dummy text!",70);
}
});
Html load code:
Code:
<script type="text/javascript" language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" ></script>
<script type="text/javascript" language="javascript" src="js/jqueryplugins.js" ></script>
<script type="text/javascript" language="javascript" src="js/libraries/gamelibrary.js"></script>
textTyping_animation(); Works, but .textAnim not