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

fidget-pincher

v0.0.10

Published

- [jsDelivr CDN](https://cdn.jsdelivr.net/npm/fidget-pincher/): `<script src="https://cdn.jsdelivr.net/npm/fidget-pincher/dist/bundle.min.js"></script>` - [unpkg CDN](https://unpkg.com/fidget-pincher/): `<script src="https://unpkg.com/fidget-pincher/dist

Downloads

61

Readme

Fidget Pincher

  • jsDelivr CDN: <script src="https://cdn.jsdelivr.net/npm/fidget-pincher/dist/bundle.min.js"></script>
  • unpkg CDN: <script src="https://unpkg.com/fidget-pincher/dist/bundle.min.js"></script>

Minimum Viable Example

<div id="fidget-pincher">
  <div class="container">
    <img draggable="false" src="https://picsum.photos/400/300" />
  </div>
</div>
<script src="https://unpkg.com/fidget-pincher/dist/bundle.min.js"></script>
<script>

  /* 1. Create a new instance of FidgetPincher */
  const fidgetPincher = new FidgetPincher({
    /* by default, all options are set to true */
    // enableInertia: false, // set to false implies all other inertia options are false
    // enableTranslateInertia: false, // inertia when touches from 1 to 0
    // enableFidgetSpinInertia: false, // inertia when touches from 2 to 1
    // enablePinchInertia: false, // inertia when touches from 2 to 0
    // stopTranslateInertiaOnTouch: false, // stop translate inertia when touches from 0 to 1
    // stopFidgetSpinInertiaOnPinch: false, // stop fidget spin inertia when touches from 1 to 2
    // stopFidgetSpinInertiaOnTouch: false, // stop fidget spin inertia when touches from 0 to 1
    // stopPinchInertiaOnPinch: false, // stop pinch inertia when touches from 1 to 2
    // stopPinchInertiaOnTouch: false, // stop pinch inertia when touches from 0 to 1
    // stopFidgetSpinInertiaOnPinchInertia: false, // stop fidget spin inertia when pinch inertia is applied
  });

  /* 2. Hook up the container, this element will listen for MouseEvent and TouchEvent */
  const container = document.querySelector('.container');
  const detach = fidgetPincher.setTouchElement(document.getElementById('fidget-pincher'), {
    onTransformed: (transform) => {
      console.log(transform.toCSSMatrix()); // return "matrix(a, b, c, d, e, f)" for css transform property
      console.log(transform.decompose()); // decompose matrix to { translateX, translateY, scale, rotate }
      const { a, b, c, d, e, f } = transform;
      console.log(a, b, c, d, e, f); // transform parameters can be directly passed to CanvasRenderingContext2D.setTransform()
      container.style.transform = transform.toCSSMatrix();
    },
  });

  /* 2b. Detach any time, listeners will be removed */
  // detach();

  /* 3. You can set transformation matrix at any time, this won't trigger onTransformed callback, next pinch movement will be relative to this matrix */
  // console.log('getTransform', fidgetPincher.getTransform()); // return { a, b, c, d, e, f }
  // let a = 1, b = 0, c = 0, d = 1, e = 0, f = 0;
  // fidgetPincher.setTransform([a, b, c, d, e, f]);  // you can pass array
  // fidgetPincher.setTransform({ a, b, c, d, e, f });  // or object
  // fidgetPincher.setTransform(`matrix(${a}, ${b}, ${c}, ${d}, ${e}, ${f})`);  // or string
  // fidgetPincher.setTransform(new FidgetPincher.TransformationMatrix(a, b, c, d, e, f));  // or instance of TransformationMatrix

  /* 4. You can also get the instance of TransformationMatrix by calling FidgetPincher.parseTransform() */
  // console.log('parseTransform', FidgetPincher.parseTransform([a, b, c, d, e, f])); // you can pass array
  // console.log('parseTransform', FidgetPincher.parseTransform({ a, b, c, d, e, f })); // or object
  // console.log('parseTransform', FidgetPincher.parseTransform(`matrix(${a}, ${b}, ${c}, ${d}, ${e}, ${f})`)); // or string
</script>
<style>
  #fidget-pincher {
    width: 400px;
    height: 300px;
    outline: 2px solid blue;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: hidden;
  }
  .container {
    width: 400px;
    height: 300px;
    position: relative;
    border: 1px solid black;
  }
</style>