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

easy-mobile

v1.1.41

Published

Touch gestures for mobile web applications.

Downloads

286

Readme

Easy Mobile

Touch gestures for mobile web applications.

Single tap, double tap, drag, pinch and swipe gestures are all supported. A little full-screen functionality is also included.

JSX support

There is now support for JSX in the form of Juxtapose. What this means is that Easy will now help you with the architecture of your large application. So although Easy elements will continue to work standalone, their use with Juxtapose is recommended.

Easy projects

Installation

You can install Easy Layout with npm:

npm install easy-mobile

You can also clone the repository with Git...

git clone https://github.com/djalbat/easy-mobile.git

...and then install the dependencies with npm from within the project's root directory:

npm install

Example

There is a small development server that can be run from within the project's directory with the following command:

npm start

The example will then be available at the following URL:

http://localhost:8888

The source for the example can be found in the src/example.js file and correspondingsrc/example folder. You are encouraged to try the example whilst reading what follows. You can rebuild it on the fly with the following command:

npm run watch-debug

The development server will reload the page whenever you make changes.

One last thing to bear in mind is that this package is included by way of a relative rather than a package import. If you are importing it into your own application, however, you should use the standard package import.

Usage

Two mixins are provided, one for the touch functionality and one for the full-screen functionality. They should be assigned to the class's prototype in the usual manner. In order to make use of the mixins, call their associated enable and disable functions when mounting and unmounting.

Touches functionality

The following listing gives an example of touch mixin usage:

import { Element } from "easy";
import { touchMixins } from "easy-movile";

class View extends Element {
  dragUpCustomHandler = (event, element, top, left) => {
    console.log("drag up", top)
  }

  ...

  didMount() {
    this.onCustomDragUp(this.dragUpCustomHandler);
    
    ...

    this.enableTouch();
  }

  willUnmount() {
    this.disableTouch();

    this.offCustomDragUp(this.dragUpCustomHandler);
    
    ...
  }
}

Object.assign(View.prototype, touchMixins);

Note that only one handler is shown. The complete list of custom touch events that can be handled is:

  • drag-up
  • drag-down
  • drag-left
  • drag-right
  • drag-start
  • swipe-up
  • swipe-down
  • swipe-left
  • swipe-right
  • pinch-move
  • pinch-start
  • single-tap
  • double-tap

As well as the usual event and element first and second arguments, the handlers can take various other arguments.

  • The single-tap and double-tap event handlers as well as the drag-start event handler have top and left additional arguments for the position of the touch.

  • The drag-up, drag-down, drag-left and drag-right event handlers also have top and left additional arguments but they are relative to the position of the touch at the start of the drag.

  • The pinch-start event handler takes no additional arguments.

  • The pinch-move event handler has a ratio additional argument that is the ratio of the distance between the two touch positions divided by the distance between the two starting touch positions.

  • The swipe-up, swipe-down, swipe-left and swipe-right event handlers have top and left additional arguments for the touch position at the start of the swipe. They also have a speed argument which is the speed of the touch position projected in the swipe's direction.

Full-screen functionality

There are two methods that the full-screen mixin provides along with the usual methods to enable and disable the functionality as well as register or deregister the handler. The following listing should suffice for an explanation:

import { Element } from "easy";
import { fullScreenMixins, fullScreenUtilities } from "easy-mobile";

import FullScreenButton from "../button/fullScreen";

const { isFullScreen } = fullScreenUtilities;

class FullScreenDiv extends Element {
  fullScreenChangeCustomHandler = (event, element) => {
    ///
  }

  fullScreenButtonClickHandler = (event, element) => {
    const fullScreen = isFullScreen();

    fullScreen ?
      this.exitFullScreen() :
        this.requestFullScreen();
  }

  didMount() {
    this.enableFullScreen();

    this.onCustomFullScreenChange(this.fullScreenButtonClickHandler)
  }

  willUnmount() {
    this.offCustomFullScreenChange(this.fullScreenButtonClickHandler)

    this.disableFullScreen();
  }

  childElements() {
    return (

      <FullScreenButton onClick={this.fullScreenButtonClickHandler} />

    );
  }

  ...
}

Object.assign(FullScreenDiv.prototype, fullScreenMixins);

There is only one full-screen custom event:

  • full-screen-change

This should always be used as there will be times when full-screen requests are denied.

Building

Automation is done with npm scripts, have a look at the package.json file. The pertinent commands are:

npm run build-debug
npm run watch-debug

Contact