Socket
Socket
Sign inDemoInstall

multi-touch-handler

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    multi-touch-handler

Multi touch handler, preparing for npm service.


Version published
Weekly downloads
4
increased by300%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Multi-touch-canvas-handler Version 2.0.2

Hello visitors , this is small script but very interest.

  • Get touch coordinates , start/end event etc for 10 fingers.
  • If you move all finger's no problem, script will handle all.
  • You can get at any time x or y position for ten fingers in canvas 2d surface.
  • I implement HUB button - detect when you finger get in rectangle .

Note:

  • If you wanna implement it with your own canvas then you no need for visualPresentation

ECMA5 Solution:

var mTouchHandler = new MultiTouchHandler();

mTouchHandler.APP.BODY.ADD_2DCANVAS(
  "canvas_2",
   mTouchHandler.SCREEN.W,
   mTouchHandler.SCREEN.H);
mTouchHandler.APP.BODY.SET_STYLE("margin: 0;padding:0;border:none;");
mTouchHandler.attachEvents();
visualPresentation(mTouchHandler);

ECMA6 Solution:

import { MultiTouchHandler, visualPresentation } from "./multi-touch";

window.onload = () => {
  /* Create instance */
  var mTouchHandler = new MultiTouchHandler();
  var canvas = mTouchHandler.APP.BODY.ADD_2DCANVAS( "canvas_2", window.innerWidth, window.innerHeight );
  mTouchHandler.APP.BODY.SET_STYLE( "margin: 0;padding:0;border:none;" );
  mTouchHandler.attachEvents( canvas );

  visualPresentation(mTouchHandler);
}

Fancy way to catch event listener :


/**
 * @description Create instance in ECMA5 style
 */

var mTouchHandler = new MultiTouchHandler();

mTouchHandler.APP.BODY.ADD_2DCANVAS("canvas_2", mTouchHandler.SCREEN.W, mTouchHandler.SCREEN.H);
mTouchHandler.APP.BODY.SET_STYLE("margin: 0;padding:0;border:none;");

mTouchHandler.attachEvents();

addEventListener("multi.touch.finger.0", function(e) {
  console.log('TOUCH FIRST FINGER')
})

addEventListener("multi.touch.finger.2", function(e) {
  console.log('TOUCH FINGER INDEX 2')
})

addEventListener("multi.touch.moving.finger.0", function(e) {
  console.log('TOUCH MOVE FIRST FINGER')
})

addEventListener("multi.touch.cancel", function(e) {
  console.log('multi.touch.cancel')
})

addEventListener("multi.touch.end", function(e) {
  console.log('multi.touch.end')
})
visualPresentation(mTouchHandler);

Keywords

FAQs

Last updated on 04 Jun 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc