Skip to content

Loading…

default options for changing timer's speed and the number of chars for e... #8

Open
wants to merge 1 commit into from

1 participant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 5, 2012
  1. default options for changing timer's speed and the number of chars fo…

    LostCrew committed
    …r each text change.
Showing with 8 additions and 3 deletions.
  1. +8 −3 javascripts/jquery.text-effects.js
View
11 javascripts/jquery.text-effects.js
@@ -57,14 +57,19 @@
};
$.fn.unscramble = function() {
+ var defaults = {
+ speed: 100,
+ chars: 25
+ };
+ var options = $.extend({ }, defaults, options);
this.each(function() {
var $ele = $(this), str = $ele.text(), replace = /[^\s]/,
- state = [], choose = [], reveal = 25, random = randomAlphaNum;
+ state = [], choose = [], reveal = options.chars, random = randomAlphaNum;
for (var i = 0; i < str.length; i++) {
if (str[i].match(replace)) {
state.push(random());
- choose.push(i);
+ choose.push(i);
} else {
state.push(str[i]);
}
@@ -82,7 +87,7 @@
for (i = 0; i < choose.length; i++) state[choose[i]] = random();
$ele.text(state.join(''));
if (choose.length == 0) clearInterval(timer);
- }, 100);
+ }, options.speed);
});
return this;
};
Something went wrong with that request. Please try again.