typeit icon indicating copy to clipboard operation
typeit copied to clipboard

Freeze/unfreeze appears to reset the queue?

Open rorosaurus opened this issue 2 years ago • 1 comments
trafficstars

I know this looks a little silly, but I'm trying to use the vanilla JS version of TypeIt. At first, this appears to be working correctly, but it ends up repeating test2, never printing test1. Is this the intended behavior? It won't resume where it left off? Or have I made some silly mistake?

The HTML element is created with test1 prepopulated, but I tested this with removing that and settings startDelete to default. I also tested by manually adding the strings with .type and .delete chained methods and got the same result.

I also noticed that freeze() wasn't stopping the cursor animation too. Is that intended behavior? The docs lead me to think no?

let aboutAuthor1TypeIt = 0;
          let aboutAuthor1 = function () {};
          if (aboutAuthor1TypeIt == 0){
            aboutAuthor1 = function () {
                aboutAuthor1TypeIt = new TypeIt("#about-author1", {
                strings: ["test2", "test1"],
                speed: 110,
                loop: true,
                lifeLike: true,
                deleteSpeed: 70,
                startDelete: true,
                cursor: false,
                afterString: async function() {
                  aboutAuthor1TypeIt.freeze();
                  window.setTimeout(aboutAuthor1, 5000);
                }
              }).go();
            }
          } else { aboutAuthor1TypeIt.unfreeze(); }

rorosaurus avatar Jan 30 '23 04:01 rorosaurus

I was eventually able to clean this up and get it working, but I think there may still be some bug present. Sometimes it will automatically reprint the original contents of the HTML element, but other times it needs to be manually passed into a .type() command. I'm stumped.

Still can't figure out why the cursor still blinks during freeze, though.

const typeItInstance2 = new TypeIt("#about-author2", {
          speed: 90,
          loop: true,
          lifeLike: true,
          deleteSpeed: 30,
          startDelete: true,
          cursor: false,
          startDelay: 0,
          nextStringDelay: 0,
          afterString: async function() {
            typeItInstance2.freeze();
            window.setTimeout(function () {
              typeItInstance2.unfreeze(); 
            }, 5000);
          }
        })
        .delete(null)
        .type("test2")
        .delete(null)
        .type("test1")
        .go();
        typeItInstance2.freeze();

rorosaurus avatar Jan 30 '23 05:01 rorosaurus