Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wildebeest/touch

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wildebeest/touch - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

jest.config.js

11

package.json
{
"name": "@wildebeest/touch",
"version": "0.1.0",
"version": "0.2.0",
"description": "Touch event module",

@@ -8,3 +8,4 @@ "main": "dist/index.js",

"scripts": {
"build": "tsc --declaration"
"build": "tsc --declaration",
"test": "jest"
},

@@ -16,5 +17,9 @@ "repository": {

"dependencies": {
"@wildebeest/common": "^0.1.0"
"@wildebeest/js-modules": "^0.1.0",
"@wildebeest/common": "^0.2.0"
},
"devDependencies": {
"@types/jest": "^24.0.11",
"jest": "^24.7.1",
"ts-jest": "^24.0.2",
"typescript": "^3.4.3"

@@ -21,0 +26,0 @@ },

@@ -7,3 +7,3 @@ import { Emitter } from "@wildebeest/common";

protected emitter: Emitter;
protected touch: any = null;
protected touch: TouchEvent;

@@ -14,3 +14,5 @@ constructor(element: any, emitter: Emitter)

this.emitter = emitter;
this.element.addEventListener('touchstart', this.setTouch.bind(this));
this.element.addEventListener('touchstart', (event: TouchEvent) => {
this.touch = event;
});
this.element.addEventListener('touchend', () => {

@@ -27,13 +29,11 @@ this.touch = null;

protected setTouch(event: any): void
protected getFingerPosition(event: TouchEvent): any
{
this.touch = {
position: {
x: event.changedTouches[0].pageX,
y: event.changedTouches[0].pageY
}
return {
x: event.changedTouches[0].clientX,
y: event.changedTouches[0].clientY
};
}
protected onMove(event: any): void
protected onMove(event: TouchEvent): void
{

@@ -44,10 +44,11 @@ if (!this.touch) {

let prevTouch: any = this.touch;
this.setTouch(event);
let lastPosition: any = this.getFingerPosition(this.touch);
let currentPosition: any = this.getFingerPosition(event);
let diff = {
horizontal: prevTouch.position.x - this.touch.position.x,
vertical: prevTouch.position.y - this.touch.position.y,
horizontal: lastPosition.x - currentPosition.x,
vertical: lastPosition.y - currentPosition.y,
}
this.emitter.emit('touchScroll', diff);
this.touch = event;
this.emitter.emit('wbTouchscroll', diff);
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc