Skip to content

Commit

Permalink
Added possibility to stop loop: use $elem.textillate('stop')
Browse files Browse the repository at this point in the history
  • Loading branch information
marmorkuchen committed Jun 8, 2014
1 parent 9ed6ae7 commit b92c705
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion jquery.textillate.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@

base.setOptions(options);

base.timeoutRun = null;

setTimeout(function () {
base.options.autoStart && base.start();
}, base.options.initialDelay)
Expand Down Expand Up @@ -204,7 +206,7 @@
} else {
index = index % length;

setTimeout(function () {
base.timeoutRun = setTimeout(function () {
base.out(function () {
run(index)
});
Expand All @@ -214,6 +216,13 @@
}(index || 0));
};

base.stop = function () {
if (base.timeoutRun) {
clearInterval(base.timeoutRun);
base.timeoutRun = null;
}
};

base.init();
}

Expand Down

0 comments on commit b92c705

Please sign in to comment.