npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-terminal-typing-effect

v1.0.2

Published

This basically creates a typing effect, like a terminal along with auto scroll depending on the height of the container for the code in the code tag , using the fucntion in the ts file.

Downloads

13

Readme

NgTerminalTypingEffect 🔥

This basically creates a typing effect, like a terminal along with auto scroll depending on the height of the container for the code in the code tag , using the fucntion in the ts file.

This project was generated with Angular CLI version 15.0.1.

You can refer the git repo : Click here

Documentation

HTML File

Enter the code for which you want the effect as shown below.

<div class="editor ">
  <pre>
    <code #codeBlock class="code-block">
      <!-- type the code here for which you want the typing effect -->
    </code>
  </pre>
</div>

TS File

ngAfterViewInit() {
      const target = this.codeBlockRef.nativeElement;
      // Highlight the code
      hljs.highlightBlock(target);
      // Get all the child nodes
      const children: Node[] = Array.from(target.childNodes);
      target.innerText = '';
      this.type(0, target, children);
    }

    type(i: number, target: HTMLElement, children: Node[]) {
      const charDelay = 25; //adjust typing speed here
      // const typingSpeed = 5;

      //checking if its the first iteration
      if (i === 0) {
        target.style.visibility = 'visible';
      }


      //checking whther the end of content so to effectively end the typing
      if (i >= children.length) {
        clearTimeout(this.typingTimeout);
        return;
      }

      const content = children[i].textContent || ''; //stores content of the current child node being typed const content = (children[i].textContent || '').split(/\s+/);

      let charIndex = 0;

      const displayChars = () => {
        if (charIndex < content.length) {
          target.appendChild(document.createTextNode(content.charAt(charIndex))); //appends a newly created text node to the target element. The text node contains the character at the current charIndex position in the content string.
          // Scroll the target element to bring the added character into view
          target.scrollTop = target.scrollHeight;

          hljs.highlightElement(target);

          charIndex++;

          this.typingTimeout = setTimeout(displayChars, charDelay);
        } else {
          if (content.includes('#')) { // a pause of 2.5 sec if the word is #
            timer(2500).subscribe(()=>{
              i++;
              this.type(i,target, children)
            })
          } else {
              i++;
              this.type(i, target, children);
          }
        }
      };
      displayChars();
    }

In the above code the last condition is the to give a pause after any desired word , there it is '#' , you can modify the code like you need.

NOTE:Highlight Js is used here to highlight the syntax.Choose the desired theme in styles.css Example:

@import '~highlight.js/styles/monokai-sublime.css';

also in the ts file make sure to import highlight js.

import hljs from 'highlight.js';

NOTE: Here ViewChild is used to connect the function to the desired tag we want the effect.

NOTE: Make sure this function is inside ngAfterViewInit(), also you can modify the typingSpeed variable for different typing speeds.

To get more help on the Angular CLI use ng help or go check out the Angular CLI Overview and Command Reference page.