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

screen-glitch

v1.0.2

Published

A React component that applies a realistic glitch effect to the entire DOM.

Downloads

5

Readme

ScreenGlitch

A React component that applies a realistic CRT monitor glitch effect to your entire application.

ScreenGlitch Demo

Installation

Install the package via npm:

npm install screen-glitch

Or via yarn:

yarn add screen-glitch

Usage

Import and use the ScreenGlitch component in your React application. The active prop controls whether the glitch effect is active.

Basic Example

import React, { useState } from 'react';
import ScreenGlitch from './components/ScreenGlitch';

const App: React.FC = () => {
  const [glitchActive, setGlitchActive] = useState(false);

  return (
    <div>
      <button onClick={() => setGlitchActive(!glitchActive)}>
        Toggle Glitch
      </button>
      <ScreenGlitch active={glitchActive} />
      {/* Rest of your app components */}
    </div>
  );
};

export default App;

Automatically Trigger Glitch on DOM Load

The following example activates the glitch effect automatically when the DOM is loaded and deactivates it after a specified duration (e.g., 5 seconds).

import React, { useEffect, useState } from 'react';
import ScreenGlitch from './components/ScreenGlitch';

const App: React.FC = () => {
  const [glitchActive, setGlitchActive] = useState(false);

  useEffect(() => {
    // Activate glitch on DOM load
    setGlitchActive(true);

    // Deactivate glitch after 5 seconds
    const timer = setTimeout(() => {
      setGlitchActive(false);
    }, 5000);

    return () => clearTimeout(timer);
  }, []);

  return (
    <div>
      <ScreenGlitch active={glitchActive} />
      {/* Rest of your app components */}
    </div>
  );
};

export default App;

Glitch During Specific Events

You can also trigger the glitch effect in response to specific events, such as clicking a button, navigating to a route, or any other custom event.

import React, { useState } from 'react';
import ScreenGlitch from './components/ScreenGlitch';

const App: React.FC = () => {
  const [glitchActive, setGlitchActive] = useState(false);

  const triggerGlitch = () => {
    setGlitchActive(true);
    // Deactivate glitch after 3 seconds
    setTimeout(() => setGlitchActive(false), 3000);
  };

  return (
    <div>
      <button onClick={triggerGlitch}>
        Trigger Glitch
      </button>
      <ScreenGlitch active={glitchActive} />
      {/* Rest of your app components */}
    </div>
  );
};

export default App;

Props

| Prop | Type | Required | Description | | ------ | -------- | -------- | -------------------------------------------- | | active | boolean | Yes | When true, activates the glitch effect |

Styling

Ensure you import the CSS file in your project to apply necessary styles for the glitch effect.

import 'screen-glitch/dist/ScreenGlitch.css';

Features

  • Realistic Glitch Effect: Simulates CRT monitor glitches with skewing, shifting, and blurring.
  • Customizable Segments: Adjust the number and size of glitch segments for desired intensity.
  • Whole-Screen Effects: Applies transformations to the entire screen for a comprehensive glitch experience.
  • Clean Cleanup: Removes all effects seamlessly when the glitch is deactivated.

Customization

You can customize various aspects of the glitch effect by modifying the ScreenGlitch.tsx file:

  • Number of Glitch Segments: Adjust the numSegments variable to increase or decrease the number of glitch overlays.
  • Skew Intensity: Modify the skew values in the applyWholeScreenSkew and applyDOMGlitches functions for more or less dramatic effects.
  • GIF Overlays: Replace or add more glitch GIFs in the glitchGifs array to diversify the glitch visuals.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

Credits

Developed by Yitz Shapiro.

License

MIT © Yitz Shapiro