0

How do I make the typing effect when the page is scrolling down? I use this code for the start of typing:

var typed = new Typed(".class", {
  strings: ["My text."],
  typeSpeed: 40,
});
Graham
  • 7,431
  • 18
  • 59
  • 84

1 Answers1

0

Considering that you need to detect scroll down event just to start the typing. You can include shabdawali js library in your code and detect for scroll down event to play pause typing effect.

var typeWriter = shabdawali(el, {
    lines : ["sentence 1", "sentence 2"],
});

var lastScrollTop = 0;
$(window).scroll(function(event){
   var st = $(this).scrollTop();
   if (st > lastScrollTop){
       // downscroll code
       typeWriter.start();
   } else {
      // upscroll code
      typeWriter.pause();
   }
   lastScrollTop = st;
});

Disclaimer: I'm the author of this plugin.

Amit Kumar Gupta
  • 7,193
  • 12
  • 64
  • 90