Giter VIP home page Giter VIP logo

typed.js's Introduction

Typed.js

View the live demo | Go to my site, mattboldt.com

Prefer Coffeescript? Check out Typed.coffee

Typed.js is a jQuery plugin that types. Enter in any string, and watch it type at the speed you've set, backspace what it's typed, and begin a new sentence for however many strings you've set.

It can be used as a subtle animation on your website, a visual demo of a note taking application, or anything else you can think of.

Weighing in at only 6kb uncompressed, it's got a small footprint and doesn't slow down the rest of your site.


Looking for some custom use cases for Typed.js? Check out the wiki


Installation

This is really all you need to get going.

<script src="jquery.js"></script>
<script src="typed.js"></script>
<script>
  	$(function(){
      	$(".element").typed({
		strings: ["First sentence.", "Second sentence."],
		typeSpeed: 0
      	});
  	});
</script>
...

<span class="element"></span>

Want the animated blinking cursor? Add this CSS.

#typed-cursor{
	opacity: 1;
	font-weight: 100;
	-webkit-animation: blink 0.7s infinite;
	-moz-animation: blink 0.7s infinite;
	-ms-animation: blink 0.7s infinite;
	-o-animation: blink 0.7s infinite;
	animation: blink 0.7s infinite;
}
@keyframes blink{
	0% { opacity:1; }
	50% { opacity:0; }
	100% { opacity:1; }
}
@-webkit-keyframes blink{
	0% { opacity:1; }
	50% { opacity:0; }
	100% { opacity:1; }
}
@-moz-keyframes blink{
	0% { opacity:1; }
	50% { opacity:0; }
	100% { opacity:1; }
}

Customization

<script>
	$(function(){
      	$(".element").typed({
			strings: ["First sentence.", "Second sentence."],
			typeSpeed: 30, // typing speed
			backDelay: 500, // pause before backspacing
			loop: false, // loop on or off (true or false)
			loopCount: false, // number of loops, false = infinite
			callback: function(){ } // call function after typing is done
      	});
 	});
</script>

Type Pausing

You can pause in the middle of a string for a given amount of time by including an escape character.

<script>
	$(function(){
      	$(".element").typed({
      		// Waits 1000ms after typing "First"
			strings: ["First ^1000 sentence.", "Second sentence."]
      	});
 	});
</script>

Get Super Custom

Want to get really custom? On my site and in the Typed.js demo I have the code type out two words, and then backspace only those two, then continue where it left off. This is done in an if statement in the backspace() function. Here's what it looks like.

...
, backspace: function(curString, curStrPos){
	...

	setTimeout(function() {

			// check string array position
			// on the first string, only delete one word
			// the stopNum actually represents the amount of chars to
			// keep in the current string. In my case it's 3.
			if (self.arrayPos == 1){
				self.stopNum = 3;
			}
			//every other time, delete the whole typed string
			else{
				self.stopNum = 0;
			}
...

This checks if the arrayPos is 1, which would be the second string you entered. If so, it sets stopNum to 3 instead of 0, which tells it to stop when there are 3 characters left. For now you'll have to create custom if statements for each specific case you want. I may automate this somehow in the future.

Wonderfull sites using Typed.js

https://commando.io/

http://testdouble.com/agency.html

http://www.stephanemartinw.com/

http://www.trelab.fi/en/

http://jessejohnson.github.io/

http://friendlydesign.co/testbuild/index.html

http://patrickelhage.com/

http://tairemadailey.com/

end

Thanks for checking this out. If you have any questions, I'll be on Twitter.

If you're using this, let me know! I'd love to see it.

It would also be great if you mentioned me or my website somewhere. www.mattboldt.com

typed.js's People

Contributors

mattboldt avatar crdunst avatar ankitr avatar f0rmat1k avatar lilith avatar

Watchers

James Cloos avatar Raphael Mu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.