Giter VIP home page Giter VIP logo

Comments (6)

schmolzp avatar schmolzp commented on July 1, 2024 1

@tameemsafi Are you still planning on adding callback methods? This would be really useful to have some control after typing has finished. Thanks!

from typewriterjs.

bhaskar-nair2 avatar bhaskar-nair2 commented on July 1, 2024 1

@tameemsafi Would make this script extremly useful if we have callback functions.

from typewriterjs.

antoniojps avatar antoniojps commented on July 1, 2024 1

@bhaskar-nair2 @schmolzp @nhaberl

I've made a quick fork and added some very simple callbacks for the main methods.
It still needs some further testing before making a pull request but it works.

Codepen Example
Github Fork

Simple example of how it works:

 var typewriter = new Typewriter(element, {
    onComplete: function (err) {
      console.log('Animation done')
    }
  })
  typewriter
    .typeString('Hello World!', function () {
      console.log('Hello World!')
    })
    .pauseFor(2500, function () {
      console.log('pause done')
    })
    .deleteAll(function () {
      console.log('deleted all')
    })
    .typeString('Strings can be removed', function () {
      console.log('Strings can be removed')
    })
    .pauseFor(2500, function () {
      console.log('pause done')
    })
    .deleteChars(7, function () {
      console.log('deleted 7 chars')
    })
    .typeString('altered!', function () {
      console.log('altered!')
    })
    .start()

from typewriterjs.

tameemsafi avatar tameemsafi commented on July 1, 2024 1

I have added callback function now, which can be chained after each method.

You can do the following:

const typewriter = new Typewriter('#app');
typewriter.typeString('Hello world!')
  .callFunction(() => {
    console.log('Finished typing string');
  })
  .start();

from typewriterjs.

antoniojps avatar antoniojps commented on July 1, 2024 1

@tameemsafi Well done, great update! 🎉

from typewriterjs.

tameemsafi avatar tameemsafi commented on July 1, 2024

Thanks for your feedback.

I am currently working on allowing HTML tags inside of the strings, but I will also add callbacks to each of the available methods.

from typewriterjs.

Related Issues (20)

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.