Typewriter Effect with jQuery sequence messages -
i trying typewriter effect jquery display messages in sequence couple of seconds between each message.
here code jsfiddle
var where, when; //added $.fn.teletype = function(opts){ var $this = this, defaults = { animdelay: 50 }, settings = $.extend(defaults, opts); var letters = settings.text.length; //added = '#' + $($this).attr('id'); //added when = settings.animdelay; //added $.each(settings.text, function(i, letter){ settimeout(function(){ $this.html($this.html() + letter); }, settings.animdelay * i); }); }; $(function(){ $('#container1').teletype({ animdelay: 100, text: 'this message 1' }); $('#container2').teletype({ animdelay: 100, text: 'this message 2' }); });
but problem messages run together
how can command time between messages?
jsfiddle updated: http://jsfiddle.net/dnkwp/19/
and code below
var where, when, iteration; //added iteration = 0; bigdelay = 0; $.fn.teletype = function(opts){ iteration++; var $this = this, defaults = { animdelay: 50 }, settings = $.extend(defaults, opts); var letters = settings.text.length; //added = '#' + $($this).attr('id'); //added when = settings.animdelay; //added if (iteration > 1) { bigdelay = bigdelay + settings.text.length * settings.animdelay; settimeout(function () { $.each(settings.text, function(i, letter){ settimeout(function(){ $this.html($this.html() + letter); }, settings.animdelay * i); }); }, bigdelay); } else { $.each(settings.text, function(i, letter){ settimeout(function(){ $this.html($this.html() + letter); }, settings.animdelay * i); }); } }; $(function(){ $('#container1').teletype({ animdelay: 100, text: 'this message 1' }); $('#container2').teletype({ animdelay: 100, text: 'this message 2' }); $('#container3').teletype({ animdelay: 100, text: 'this message 3' }); $('#container4').teletype({ animdelay: 100, text: 'this message 4' }); }); // added reversing function
jquery
No comments:
Post a Comment