Code Monkey home page Code Monkey logo

ityped's Introduction

iTyped

npm package

Dead simple Animated typing, with no dependencies.

Demo ➞

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.


Features

  • iTyped has a tiny size: 2 kB.
  • iTyped has no jQuery dependency.
  • Just install and enjoy!
  • Placeholder input support.

At now, if you just need to render Strings, iTyped is the best solution for you.

Installation

NPM

npm install ityped

Yarn

yarn add ityped

Browser

https://unpkg.com/[email protected]

CSS

CSS animations are build upon initialzation in JavaScript. But, you can customize them at your will! These classes are:

/* Cursor */
.ityped-cursor {}

Want the animated blinking cursor?

.ityped-cursor {
    font-size: 2.2rem;
    opacity: 1;
    -webkit-animation: blink 0.3s infinite;
    -moz-animation: blink 0.3s infinite;
    animation: blink 0.3s infinite;
    animation-direction: alternate;
}

@keyframes blink {
    100% {
        opacity: 0;
    }
}

@-webkit-keyframes blink {
    100% {
        opacity: 0;
    }
}

@-moz-keyframes blink {
    100% {
        opacity: 0;
    }
}

Use with multiples instances at the same time

<span id="one"></span>
<span id="other"></span>
  import { init } from 'ityped'
  
  const oneElement = document.querySelector('#one')
  const otherElement = document.querySelector('#other')
  
  init(oneElement, { showCursor: false, strings: ['Nice', 'One' ] });
  init(otherElement, { disableBackTyping: true, strings: ['iTyped is', 'Awesome'] });

Use with React.js

  import React, { Component } from 'react'
  import { init } from 'ityped'
  
  export default class Hello extends Component {
    componentDidMount(){
      const myElement = document.querySelector('#myElement')
      init(myElement, { showCursor: false, strings: ['Use with React.js!', 'Yeah!' ] })
    }
    render(){
      return <div id="myElement"></div>
    }
  }

Customization

  init("#element", {
  
    /**
     * @param {Array} strings An array with the strings that will be animated 
     */
     strings: ['Put your strings here...', 'and Enjoy!']
    
    /**
     * @param {Number} typeSpeed Type speed in milliseconds
     */
     typeSpeed:  100,
   
    /**
     * @param {Number} backSpeed Type back speed in milliseconds
     */
     backSpeed:  50,
    
    /**
     * @param {Number} startDelay Time before typing starts
     */
     startDelay: 500,
    
    /**
     * @param {Number} backDelay Time before backspacing
     */
     backDelay:  500,
    
    /**
     * @param {Boolean} loop The animation loop
     */
     loop:       false,
    
    /**
     * @param {Boolean} showCursor Show the cursor element
     */
     showCursor: true,
    
    /**
     * @param {Boolean} placeholder Write the string in the placeholder content
     */
     placeholder: false,
    
    /**
     * @param {Boolean} disableBackTyping Disable back typing for the last string sentence 
     */
     disableBackTyping: false,
    
    /**
     * @property {String} cursorChar character for cursor
     */
     cursorChar: "|",
    
    
    // optional: The callback called (if `loop` is false) 
    // once the last string was typed
    /**
     * @property {Function} onFinished The callback called , if `loop` is false,
     * once the last string was typed
     */
    onFinished: function(){},
  }

Thanks for checking this out.

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

ityped's People

Contributors

ashishg-qburst avatar ck3gemproject avatar danielrosenwasser avatar dschau avatar felipe-campos avatar luisvinicius167 avatar olivierbossel avatar zhuweiyou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ityped's Issues

Garbage Values

was working for me until two days ago now it does not accept more than one string without becoming garbage values.

Loop delay

It would be nice to have a feature to wait in between each loop

add a tag/id/class to typed string

hello there. very nice project! you got my star. I was wandering if it is possible to add a tag or a class to the strings.
In my unicorn world it would work like this:

window.ityped.init(document.querySelector("#typedTest"),{
strings: ["try this", "and THIS", and this],
loop : false,
disableBackTyping: true
})

thanks a lot

m

init can accept the dom element

Thanks to awesome ityped !

Do you want to request a feature or report a bug?

feature

What is the current behavior?

When I try to combine the vue directive to ityped, I must get the DOM element CSS Path

What is the expected behavior?

would wonderful If the init function can accept DOM element type.

How to use this without webpack/es6

Is there a guide on how to use this without using import and the new EcmaScript syntax, or js libraries like webpack? I am just trying to use it as in my HTML

Text doesn't appear in IE11/Win 7

I've been browser testing a new website in IE11 (Windows 7) and the animation of the text doesn't start, just the blinking cursor. I've double checked my installation by running your website (https://ityped.surge.sh/) and the same issue can be seen there.

random strings

what you think about add a boolean to randomize string displayed from array?

Start Delay Parameter

I've entered the startDelay parameter but the delay doesn't seem to be going into effect. Any suggestions would be greatly appreciated - thank you!

Can't find a way to reset the strings after initialise it.

I need to change the strings for a whole new set from time to time. I've tried just to call again the init(), giving the proper parameters, but it didn't work. Then, I tried to call destroy() before reinitialise the component, but no luck!

Any suggestion?

`#element` + document undefined

This may be a dumb question, but what is #element ? What is its purpose or function?

How would I go about using the following in React? Just throw it in a div?

init(`#element`, {
  // required - for now, only accepting texts
    strings: ['Dead simple animated typing.', 'No dependencies'],
    //optional

Also, when I try to paste in the example code, I get ReferenceError: document is not defined

Cancel option

Is there a cancel method?

I'm using react but if a unmount the view the callback onFinished still active and generate some errors with this.setState react method, because the element is not mounted.

Thanks.

Rewriting ityped

As I’ve said in my PR, I really liked your lib and thought I could contribute some tweaks.

As I started digging into it, I was struggling to distribute the ideas into concise and intuitive PRs. So, I decided to just write everything and then reach to you to check if you’re interested in seeing and discussing the changes in order to improve the overall result.

I wouldn’t say I’ve finished, but the code does work and it’s got smaller and easier, imho. It is 107 lines long right now.

What do you say?

Se quiser, podemos falar em português pelo FB. Vou deixar um comentário lá no seu post na JavaScript Brasil.

count is not defined (es2015?)

Interesting, unless I add this line, the browser will throw 'count is not defined':

+    window.count = 0                                                                                                            
      init('#typer', {       ....}

Maybe this is because im using ityped in an vue2 environment?

two of each string character?

Screen Shot 2022-08-09 at 10 27 31 AM

After I place my strings in the specified places per the documentation, when the page is rendered it is doubling the letter for each of the strings in the array. Is this a version issue that might be happening?

I am using in my package.json:
"ityped": "^1.0.3", "react": "^18.2.0",

IDEA: Delete just some of the letters

Not issue, but idea.

I think, that an option to delete just some of the letters, not only whole paragraph, would be nice.
For example, "I like apples" is being typed and later only "apples" is removed and replaced with "oranges".

BTW. Nice library

Force line breaks - Possible?

Hello,

Is it possible to make the following work?

strings:['I don\'t want just words.<br/>If that\'s all you have for me, you\'d better go.<br/>F. SCOTT FITZGERALD'],

When I try the above, <br/>s can literally be seen being typed on the page and then once the typing finishes, they go away.

Is it possible to prevent all instances of <br/> from being typed, yet parsed in the HTML?

i.e., simulate the following sequence: animate the typing of a sentence, hit return, another sentence, hit return etc.

Strings merge after switching tabs

While iTyped is printing the string, I can switch to a different tab. However, when I switch back, it seems to be typing a new string without removing the old one. Fortunately, the merged string is removed at the end of the session, but I still don't know how to prevent the merging from occurring.

Support language translation

Hey! First of all congratulations for a great tool.

Secondly, I would like to ask/suggest if there's a way I can dinamically change the language of the strings I'm typing (with i18next library) without having coherence problems.

Example to style cursor pointer animation

I saw that you use in the examples in final of README to animate cursor , this:

@keyframes blink{
    0% { opacity:1; }
    50% { opacity:0; }
    100% { opacity:1; }
}

You can use the property animation-direction using the reverse or alternate value , to no need apply the same state of moment 0%at moment 100% .

That it just apply the same effect start's animation.

Disable back typing?

Hello — this is a great tool, but I only need it to type onto the screen, not have the animated removal. Is there anyway to disable the animated back-typing?

Add semver tags?

Hi man,
Hope you are doing well :)
Is that possible to tag the releases with semver versioning?
I'm planning to use your library but I'm afraid about none compatibilities issues in the future...
Thanks in advance!

Cheers!

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.