Comments (6)
@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.
The suggestion behavior, how does it work? Can you give some examples?
from typewriterjs.
Please provide more details on how you would like this featured to work. Closing for now.
from typewriterjs.
I believe this person is talking about form elements or placeholders
from typewriterjs.
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.
Curious, will this work with <textarea>
too?
from typewriterjs.
Related Issues (20)
- Bug when deleting chars in subsequent run, even on the main site HOT 3
- How long is the time interval between letters when the delay option is set to 0? HOT 1
- TypewriterJS not working in a next.js app router HOT 1
- Typo HOT 2
- Add `map` files HOT 1
- Typewriter paused when tab/window is not active HOT 1
- Feature Request: Method to ClearAll immediately. HOT 7
- Can I attach a css class to it? When I add a class to the parent element to set a custom font, it doesn't work. HOT 1
- Issue with iPhone & RTL HOT 2
- Can i change de delay value meanwhile the effect is active?
- [Feature request] Add option to skip typing certain tags
- Font Size for style wrapper not working
- TypeScript: Type Error when injecting graphemeSplitter on stringSplitter `option` as per the documented demo
- Doesnt work with emojis
- Why does it delete the text??
- Feature Request - Add Option for Wrapper to Get Height of Fully Typed Content
- Safari does not connect scripts / apply opentype font features / kerning to text created with createTextNode HOT 1
- CDN version is broken
- How to completely stop the typing using React
- How to display initial text?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typewriterjs.