Giter Club home page Giter Club logo

Comments (6)

tameemsafi avatar tameemsafi commented on June 2, 2024 3

@mvanroon thanks for the feedback, I have added two options now called onCreateTextNode and onRemoveNode. You can see below for an example of how to use it with input placeholder.

var input = document.getElementById('input')

var customNodeCreator = function(character) {
  // Add character to input value
  input.placeholder = input.placeholder + character;

  // Return null to skip internal adding of dom node
  return null;
}

var onRemoveNode = function({ character }) {
  if(input.value) {
    // Remove last character
    input.placeholder = input.placeholder.slice(0, -1)
  }
}

var typewriter = new Typewriter(null, {
  loop: true,
  delay: 75,
  onCreateTextNode: customNodeCreator,
  onRemoveNode: onRemoveNode,
});

typewriter
  .typeString('A simple yet powerful native javascript')
  .pauseFor(300)
  .start();

from typewriterjs.

Sigmus avatar Sigmus commented on June 2, 2024

The suggestion behavior, how does it work? Can you give some examples?

from typewriterjs.

tameemsafi avatar tameemsafi commented on June 2, 2024

Please provide more details on how you would like this featured to work. Closing for now.

from typewriterjs.

patcon avatar patcon commented on June 2, 2024

I believe this person is talking about form elements or placeholders

from typewriterjs.

mvanroon avatar mvanroon commented on June 2, 2024

Would love to apply this to an input's placeholder attribute as well.
Something along the lines of:

new Typewriter('#typewriter', {
  attribute: 'placeholder', // defaults to 'text' or 'innerText'
  strings: ['Hello', 'World'],
  autoStart: true,
});

or

new Typewriter({ // Make first parameter optional?
  strings: ['Hello', 'World'],
  onChange: output => this.input.setAttribute('placeholder', output),
  autoStart: true,
});

I'd up for making a PR. Thoughts?

from typewriterjs.

connorwforsyth avatar connorwforsyth commented on June 2, 2024

Curious, will this work with <textarea> too?

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.