Comments (6)
You are able to chain the deleteAll
function anywhere and it will be called once it reaches that stage.
Example:
https://jsfiddle.net/2dwL47bu/
from typewriterjs.
Thanks for your reply, I am aware of that, the point is that it has to reach that point, i.e. the string has to be fully typed out and there's no way to cancel that and directly skip to the next step.
I was asking for a feature to clear the current event queue and start a new one, so I don’t think this issue is resolved.
Edit: to clarify further, I think the way this plugin works right now is that for every chained call, it adds an entry to a queue-array and keeps working off this queue in a first-in-first-out basis (or looping over it in case looping is enabled). What I would like to see would be a way to cancel all still remaining items in the queue, hence flushing / emptying it, and starting from scratch as if I was first instantiating the typewriter. I hope this makes it more clear.
from typewriterjs.
Thank you for your reply. You are correct regarding the queue system. However, there must be a point in the queue for it to call some kind of method to flush the queue. So it would not be possible to include the function you are requesting. This would essentially mean doing a check after processing each item in the queue in order to flush the queue at a certain point, which I think is incorrect for what you need.
You can achieve what you need through the current API. Use the javascript MutationObserver
in order to listen for any changes in the wrapper element. Then you can check if the wrapper element meets a condition and stop the typewriter instance and re-create it again.
Example:
https://jsfiddle.net/yxLmvq8c/
from typewriterjs.
I only glanced over the source code, so I could be wrong here, but wouldn’t a method on the typewriter instance itself suffice? Say there’s a method flush()
that stops the typewriter and flushes the queue when called externally (so not as part of a chain) and then the queue can be filled again like usual? The state the instance was in could be kept as the initial state for the new queue, i.e. if a word was currently being typed it would still stay visible up to the point it was typed and could be modified by subsequent calls.
In any case, thank you for your example, I guess I could simply replace the typewriter instance whenever I need it to restart—I’ll have to find a way to make it look less jagged though.
from typewriterjs.
No problem, I think re-creating the whole instance would be better than flushing the queue as this would only be required in very specific circumstances. You have full control over the object that is created, so you can choose when to re-create it. I hope that works for you, but would be happy to re-consider if it becomes a problem for other users of the plugin.
from typewriterjs.
Yes, I think you have a valid point there. Thanks for your help and suggestions and being open about reconsidering should it come up again! 👍
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.