javascript - Jquery TypeWriter Effect variable change -
i'm attempting create jquery typewriter effect scrolls through different sentences each 10 seconds. @ 10 second break style of site changes. problem after first run through sentences turn gibberish variable 'text_number' keeps getting changed , i'm not sure why.
any appreciated.
var textone = '"hello world"'; var texttwo = '"what happening"'; var textthree = 'good morning'; function text_change(text_number) { if (text_number === 1) { var splittext = textone.split(""); } else if (text_number === 2) { var splittext = texttwo.split(""); } else if (text_number === 3) { var splittext = textthree.split(""); } var n = splittext.length; function text_animation(textpos) { var previousi = textpos - 1; var nextletter = splittext.slice(previousi, textpos); if (nextletter == '*') { $("#quote-div p").append("<br>"); } else { $("#quote-div p").append(nextletter); } } = 0; setinterval(function() { i++; if (i <= n) { text_animation(i); } }, 0200); } var site = 1; //animate site function function animate_site(site_number) { if (site_number == 1) { //extra css site changes $("#quote-div p").empty(); text_change(site_number); } else if (site_number == 2) { //extra css site changes $("#quote-div p").empty(); text_change(site_number); } else if (site_number == 3) { //extra css site style change each 10 seconds $("#quote-div p").empty(); text_change(site_number); site = 0; } } function animate_site_loop() { setinterval(function() { site++; animate_site(site); }, 10000); } $(document).ready(function() { animate_site_loop(); text_change(site); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <div id="quote-div"> <p></p> </div>
Comments
Post a Comment