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

slytherin

v0.4.3

Published

A Global Drag Listener

Downloads

3

Readme

   _    _
,-(|)--(|)-.
\_   ..   _/ Slytherin: Framework-independent slithering utility.
  \______/              Makes things draggable.
    V  V

Demo

Visit bytesized.tv/slytherin for a quick demo.

Why?

slytherin is a drag helper: It makes DOM nodes draggable.

Yes, there are many great drag&drop libraries out there; so why a new one? Well, I created this library mostly for educational purposes. — There will be a screencast about it soon in ByteSized.TV.

My goal was to show that creating a drag utility is not that hard, and can be done under, say, fifty lines of code.

In addition, I wanted something “very” lightweight for my personal use (in JediFocus). So slytherin is also here to scratch my own itch :)

In the end, it does what it says is does: Nothing more, nothing less.

Installation

yarn add slytherin

or

npm install slytherin

Usage Example

For additional examples with comments and documentation see the examples folder.

The following shows a simple React component that uses slytherin to make a part of it draggable.

Aside

Slytherin provides framework-agnostic init, start, and stop endpoints, so you don’t have to use it with React — You can practically use it with any front-end framework of your liking.

import { start, stop, init } from 'slytherin';

import React, { Component } from 'react';
import { render } from 'react-dom';

class SimpleApp extends Component {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    // Start listening to drag events.
    start();

    const box = document.querySelector('.box');

    if (!box) {
      return;
    }

    // `init` gives the box super powers:
    // makes it draggable.
    init(box, {
      dragClassName: 'box--shadow',
      dragHandleClassName: 'box__header'
    });
  }

  componentWillUnmount() {
    // The component is doing a harakiri:
    // Stop listening to drag events.
    stop();
  }

  render() {
    return (
      <div className="wrapper">
        <div className="box">
          <div className="box__header">A Draggable Box</div>
          <div className="box__body">
            <p>Repello Inimicum!</p>
            <p>Salvio Hexia!</p>
            <p>Repello Muggletum!</p>
            <p>Protego Maxima!</p>
            <p>Fianto Duri!</p>
            <p>Repello Inimicum!</p>
          </div>
        </div>
      </div>
    );
  }
}

const reactRoot = document.getElementById('react-root');

if (reactRoot) {
  render(<SimpleApp />, reactRoot);
}

Yarn Scripts

  • yarn run lint: Lints the project
  • yarn test: For now, same as yarn run lint.
  • yarn serve-examples: Creates a simple http server to serve the examples.
  • yarn run watch-examples: Creates the bundles required for the examples to run. Starts webpack in watch mode.

Wanna Help?

Any help is more than appreciated.

If you want to contribute to the source code, fork this repository and create a pull request.

In lieu of a formal style guide, take care to maintain the existing coding style.

Also, don’t forget to add unit tests for any new or changed functionality.

If you want to report a bug; or share a comment or suggestion, file an issue.

I’ve Found a Bug; I Have an Idea

For bug reports and suggestions, please file an issue.

Contact Information

License

MIT-licensed. — See the license file for details.

Code of Conduct

We are committed to making participation in this project a harassment-free experience for everyone, regardless of the level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.

See the code of conduct for details.

A ByteSized.TV Project

This repository is a part of the Byte-Sized JavaScript VideoCasts.

It is a compilation of short (around ten minutes) screencasts about JavaScript and related technologies.

Learn, explore, and have fun!