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

besom

v2.0.5

Published

A Javascript Library For Multi-Touch or Mouse Event Gestures (tap, longtap, doubletap, pinch, slide, rotate)

Downloads

19

Readme

Besom

A Javascript Library For Multi-Touch and Mouse Event Gestures (tap, longtap, doubletap, pinch, slide, rotate)

Installation

npm install besom --save or yarn add besom or cdn https://cdn.jsdelivr.net/npm/besom/dist/besom.min.js

Usage

  var Besom = require('besom'), g = Besom.create(document.getElementById('demo'));
  g.enable('longtap', 'slide', 'pinch');

  //bind Event
  g.on('tap', function(){ console.log('tap') }); //tap event is enabled by default
  g.on('longtap', function(){ console.log('longtap') });

  g.on('slide', function(e){ this.translate(e.translate) });
  g.on('slideEnd', function(){ console.log('slideEnd')  });

  g.on('start', function(e){
    if(e.count == 2) this.setPointAsOrigin(e.center)
  })
  g.on('pinch', function(e){ this.scale(e.scale) });
  g.on('pinchEnd', function(){ console.log('pinchEnd') });

See Demos Click Here

Supported Gestures

  • tap(enabled default)
  • longtap
  • doubletap
  • slide
  • pinch
  • rotate

Bind Event Name

  • tap
  • longtap
  • doubletap
  • start
  • slide
  • slideEnd
  • pinch
  • pinchEnd
  • rotate
  • rotateEnd

Instance And Methods

Create Gestures Maintainer
Besom.create(element)
  • element:HTMLElement
Gestures Maintainer Methods
  • enable(gesture), disable(gesture) - enable/disable gestures

  • on(event, fn) - add gesture event function

    the parameter of the event callback function - fn(currentGestureEventObject, startGestureEventObject, currentTransformableElement)

    • currentGestureEventObject and startGestureEventObject is the formatted event object with caculated datas of the gestures
    • currentTransformableElement or this in the callback function fn - refers to the transformable element. More details see bellow
  • delegate(className, event, fn) - delegate the gesture of the child element which has the className className

  • destroy() - destroy the gesture manager and events

Create Transformable Element
Besom.element(element)
  • element:HTMLElement.
Transformable Element Properties and Methods
  • element - the html element
  • transform - the transform property of the element
  • offset() - return the element offset.left and offset.top in the page
  • getPointOrigin(point) - caculate the point({pageX:number, pageY:number) in the element matrix
  • setPointAsOrigin(point) - set the point({pageX:number, pageY:number}) as the element origin
  • translate(offset, duration) - translate offset.x as horizon and offset.y as vertical distance in duration time.
  • scale(scale, duration)
  • rotate(rotate, duration)
  • position() - return the left and top styles of the element.
  • move(params, duration) - move the element to the postion(different to translate) with params({ left, top, width, height }) in duration time.