Skip to content

Commit

Permalink
Merge in #32, add tiEmpty() companion function.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmacarthur committed Apr 4, 2017
1 parent 9a13a32 commit 88b69ae
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<pre>Update: TypeIt is fully compatible with jQuery 3.1.1+!</pre>
<pre>Update: TypeIt is fully compatible with jQuery 3.2.1+!</pre>

# TypeIt: The Most Versatile jQuery Animated Typing Plugin on the Planet

Expand Down Expand Up @@ -105,8 +105,8 @@ For example:
| Function | Arguments | Description
| ------------- | ------------- | ------------- |
| tiType() | (string) Characters (including those wrapped in HTML) to be typed. | Will type the characters. |
| tiDelete() | (number) Number of characters to be deleted from what's already been typed. | Will delete the number of
| tiPause() | (number) Number of milliseconds to pause before continuing. | Will pause the specified number of milliseconds.|
| tiDelete() | (number) Number of characters to be deleted from what's already been typed. | Will delete the specified number of characters. |
| tiEmpty() | (none) | Will instantly delete everything that has already been typed.
| tiPause() | (number) Number of milliseconds to pause before continuing. | Will pause the specified number of milliseconds.|
| tiBreak() | (none) | Will break the typing to a new line.|
| tiSettings() | (JSON) Options you'd like to update | Will redefine your options on the fly. This will only work for updating the `speed`, `lifeLike`, and `html` options.|
Expand Down
17 changes: 16 additions & 1 deletion dev/typeit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* jQuery TypeIt
* @author Alex MacArthur (http://macarthur.me)
* @version 4.3.0
* @version 4.4.0
* @copyright 2016 Alex MacArthur
* @description Types out a given string or strings.
*/
Expand Down Expand Up @@ -205,6 +205,14 @@
}
},

/*
Empty the existing text, clearing it instantly.
*/
empty: function() {
this.tel.html('');
this._executeQueue();
},

/*
If show cursor is enabled, move array starting point for the for loop back one,
so that the loop will not find the closing tag and delete the cursor.
Expand Down Expand Up @@ -443,6 +451,13 @@
return this;
};

$.fn.tiEmpty = function() {
var i = $(this).data('typeit');
if (i === undefined) return $doc;
i.queue.push([i.empty]);
return this;
};

$.fn.tiDelete = function(num) {
var i = $(this).data('typeit');
if (i === undefined) return $doc;
Expand Down
24 changes: 23 additions & 1 deletion dev/typeit.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion dist/typeit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* jQuery TypeIt
* @author Alex MacArthur (http://macarthur.me)
* @version 4.3.0
* @version 4.4.0
* @copyright 2016 Alex MacArthur
* @description Types out a given string or strings.
*/
Expand Down Expand Up @@ -205,6 +205,14 @@
}
},

/*
Empty the existing text, clearing it instantly.
*/
empty: function() {
this.tel.html('');
this._executeQueue();
},

/*
If show cursor is enabled, move array starting point for the for loop back one,
so that the loop will not find the closing tag and delete the cursor.
Expand Down Expand Up @@ -443,6 +451,13 @@
return this;
};

$.fn.tiEmpty = function() {
var i = $(this).data('typeit');
if (i === undefined) return $doc;
i.queue.push([i.empty]);
return this;
};

$.fn.tiDelete = function(num) {
var i = $(this).data('typeit');
if (i === undefined) return $doc;
Expand Down
Loading

0 comments on commit 88b69ae

Please sign in to comment.