Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New option: onBegin(). A custom event before it begins typing. #337

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ var typed = new Typed(".element", {
*/
contentType: 'html',

/**
* Before it begins typing
* @param {Typed} self
*/
onBegin: (self) => {},

/**
* All typing is complete
* @param {Typed} self
Expand Down
1 change: 1 addition & 0 deletions assets/demos.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ document.addEventListener('DOMContentLoaded', function() {
startDelay: 1000,
loop: false,
loopCount: Infinity,
onBegin: function(self) { prettyLog('onBegin ' + self) },
onComplete: function(self) { prettyLog('onComplete ' + self) },
preStringTyped: function(pos, self) { prettyLog('preStringTyped ' + pos + ' ' + self); },
onStringTyped: function(pos, self) { prettyLog('onStringTyped ' + pos + ' ' + self) },
Expand Down
9 changes: 9 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ Returns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refer

- `contentType` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** 'html' or 'null' for plaintext

### onBegin

Before it begins typing

**Parameters**

- `self` **[Typed](#typed)**


### onComplete

All typing is complete
Expand Down
42 changes: 41 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ <h3 class='mb0 no-anchor'></h3>
class='regular pre-open'>
.contentType
</a></li>


<li><a
href='#defaults.onBegin'
class='regular pre-open'>
.onBegin
</a></li>

<li><a
href='#defaults.onComplete'
class='regular pre-open'>
Expand Down Expand Up @@ -1083,6 +1089,40 @@ <h3 class='fl m0' id='defaults'>
</div>
</div>

<div class='border-bottom' id='defaults.onBegin'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
<span class='code strong strong truncate'>onBegin(self)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>



<p>Before it begins typing</p>

<div class='pre p1 fill-light mt0'>onBegin(self: <a href="#typed">Typed</a>)</div>

<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>

<div class='space-bottom0'>
<div>
<span class='code bold'>self</span> <code class='quiet'>(<a href="#typed">Typed</a>)</code>

</div>

</div>

</div>

</section>

</div>
</div>

<div class='border-bottom' id='defaults.onComplete'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ <h2 id="basic">Basic Demo</h2>
backDelay: 500,
startDelay: 1000,
loop: false,
onBegin: function(self) { prettyLog('onBegin ' + self) },
onComplete: function(self) { prettyLog('onCmplete ' + self) },
preStringTyped: function(pos, self) { prettyLog('preStringTyped ' + pos + ' ' + self); },
onStringTyped: function(pos, self) { prettyLog('onStringTyped ' + pos + ' ' + self) },
Expand Down
Loading