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

scrambling-text-next

v1.0.0

Published

A super lite (4.29 kB │ gzip: 1.20kB) JavaScript library written in vanilla js with ready to use components for React, Vue for scrambling text.

Downloads

20

Readme

A super lite (4.29 kB │ gzip: 1.20kB) JavaScript library written in vanilla js with ready to use components for React, Vue for scrambling text.

Check out the demo 🚀

This library was forked from sogoagain/scrambling-text-js and updated to use most modern JavaScript features and to be more lightweight.

Table of Contents

Installation

npm i scrambling-text-next

or

yarn add scrambling-text-next

Examples

Vanilla


import Scramble from "scrambling-text-next";

document.addEventListener("DOMContentLoaded", () => {
  const elm = document.querySelector(".vanilla-text") as HTMLElement;

  const update = (str: string) => {
    elm.textContent = str;
  };

  const Scrambler = new Scramble();

  elm.addEventListener("click", () => {
    Scrambler.scramble(elm.textContent!, {
      onIteration: update,
    });
  });

Scramble

 

  • Vue

<script lang="ts" setup>
import { Scramble } from "scrambling-text-next/vue";
</script>
<template>
  <Scramble :delay="1000">
    WILL SCRAMBLE AFTER A SEC
  </Scramble>
</template>

 

  • React

import { Scramble } from "scrambling-text-next/react";

export default function Page() {
  return <Scramble delay={1000}> WILL SCRAMBLE AFTER A SEC</Scramble>;
}

ScrambleInView

 

  • Vue

<script lang="ts" setup>
import { ScrambleInView } from "scrambling-text-next/vue";
</script>
<template>
  <ScrambleInView :once="false">
    WILL SCRAMBLE ANYTIME IN VIEW
  </ScrambleInView>
</template>

 

  • React

import { ScrambleInView } from "scrambling-text-next/react";

export default function Page() {
  return (
    <ScrambleInView once={false}> WILL SCRAMBLE ANYTIME IN VIEW</ScrambleInView>
  );
}

ScrambleOnHover

 

  • Vue

<script lang="ts" setup>
import { ScrambleOnHover } from "scrambling-text-next/vue";
</script>
<template>
  <ScrambleOnHover>
    WILL SCRAMBLE ANYTIME HOVERED
  </ScrambleOnHover>
</template>

 

  • React

import { ScrambleOnHover } from "scrambling-text-next/react";

export default function Page() {
  return <ScrambleOnHover> WILL SCRAMBLE ANYTIME HOVERED</ScrambleOnHover>;
}

Caveats

Scramble a link

  • Vue

<script lang="ts" setup>
import { ScrambleOnHover } from "scrambling-text-next/vue";
</script>
<template>
    <ScrambleOnHover
        elm="a"
        props={{
          href: 'https://github.com/UnCor3/scrambling-text-next'
          target: '_blank'
        }}
      >
        STAR THIS REPO
      </ScrambleOnHover>
</template>
  • React

import { ScrambleOnHover } from "scrambling-text-next/react";

export default function Page() {
  return (
    <ScrambleOnHover
      elm="a"
      props={{
        href: "https://github.com/UnCor3/scrambling-text-next",
        target: "_blank",
      }}
    >
      STAR THIS REPO
    </ScrambleOnHover>
  );
}

Types

 

  • Vanilla

 

Scrambler class is the default export


export type OnIteration = (scrambledText: string) => void;

export type OnFinished = (scrambledText: string) => void;

type Options {
    /*On every text change*/
  onIteration: OnIteration;
    /*On text change finished*/
  onFinished?: OnFinished;
    /**
     * Characters to scramble
     *  @default ["@", "#", "$", "%", "£", "&", "*", "§", "+", "_"] and alphabet,
     *
     */
  characters?: string[];
    /**
        Prevent getting called multiple times, if set to false and called more than once you will break the iteration
        @default true
    */
  preventGettingCalledMultipleTimes?: boolean;
}

class Scrambler {
  scramble(text: string, _options: Options): void;
}

 

  • React

 

  • Scramble Types

{
    /**
     * Text to be scrambled
     */
    children: string;
    /**
     * Html element type
     * @default "span"
     */
    elm?: keyof ReactHTML;
    /**
     * Any kind of prop that can be passed to an element
     */
    props: React.HTMLProps<HTMLElement>;
    /**
     * Delay to start in ms
     */
    delay?: number;
}

 

  • ScrambleOnHover Types

{
    /**
     * Pass true to scramble once
     */
    once : boolean;
    /**
     * Text to be scrambled
     */
    children: string;
    /**
     * Html element type
     * @default "span"
     */
    elm?: keyof ReactHTML;
    /**
     * Any kind of prop that can be passed to an element
     */
    props: React.HTMLProps<HTMLElement>;
    /**
     * Delay to start in ms
     */
    delay?: number;
}

 

  • ScrambleInView Types

{
    /**
     * Pass any options that can be passed to IntersectionObserver
     */
    observerOptions?: IntersectionObserverInit;
    /**
     * Pass true to scramble once
     */
    once : boolean;
    /**
     * Text to be scrambled
     */
    children: string;
    /**
     * Html element type
     * @default "span"
     */
    elm?: keyof ReactHTML;
    /**
     * Any kind of prop that can be passed to an element
     */
    props: React.HTMLProps<HTMLElement>;
    /**
     * Delay to start in ms
     */
    delay?: number;


}

 

  • Vue

 

  • Scramble Types

{
    /**
     * Html element type
     * @default "span"
     */
    elm?: keyof HTMLElementTagNameMap;
    /**
     * Any kind of prop that can be passed to an element
     */
    props: Record<string, any>;
    /**
     * Delay to start in ms
     */
    delay?: number;
}

 

  • ScrambleOnHover Types

{
    /**
     * Pass true to scramble once
     */
    once : boolean;
    /**
     * Html element type
     * @default "span"
     */
    elm?: keyof HTMLElementTagNameMap;
    /**
     * Any kind of prop that can be passed to an element
     */
    props: Record<string, any>;
    /**
     * Delay to start in ms
     */
    delay?: number;
}

 

  • ScrambleInView Types

{
    /**
     * Pass any options that can be passed to IntersectionObserver
     */
    observerOptions?: IntersectionObserverInit;
    /**
     * Pass true to scramble once
     */
    once : boolean;
    /**
     * Html element type
     * @default "span"
     */
    elm?: keyof HTMLElementTagNameMap;
    /**
     * Any kind of prop that can be passed to an element
     */
    props: Record<string, any>;
    /**
     * Delay to start in ms
     */
    delay?: number;
}