Socket
Socket
Sign inDemoInstall

touchsweep

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

touchsweep - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

dist/touchsweep.d.ts

11

dist/touchsweep.js

@@ -28,2 +28,10 @@ (function (global, factory) {

var TouchSweep = /*#__PURE__*/function () {
/**
* Create a new TouchSweep instance
* @constructor
* @param {HTMLElement} element
* @param {any} data
* @param {number} threshold
* @return {TouchSweep}
*/
function TouchSweep() {

@@ -115,5 +123,4 @@ var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.body;

return;
} // TODO: Check browser support
}
var event = new CustomEvent(eventName, {

@@ -120,0 +127,0 @@ detail: this.eventData

10

dist/touchsweep.min.js

@@ -1,2 +0,8 @@

(function(a,b){if("function"==typeof define&&define.amd)define(["exports"],b);else if("undefined"!=typeof exports)b(exports);else{var c={exports:{}};b(c.exports),a.touchsweep=c.exports}})("undefined"==typeof globalThis?"undefined"==typeof self?this:self:globalThis,function(a){"use strict";function b(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function c(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function d(a,b,d){return b&&c(a.prototype,b),d&&c(a,d),a}Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=void 0;var e=/*#__PURE__*/function(){function a(){var c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:document.body,d=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:40;return b(this,a),this.element=c,this.eventData=d,this.threshold=e,this.coords={startX:0,startY:0,endX:0,endY:0},this.onStart=this.onStart.bind(this),this.onEnd=this.onEnd.bind(this),this.bind(),this}return d(a,[{key:"onStart",value:function onStart(a){this.coords.startX=a.changedTouches[0].screenX,this.coords.startY=a.changedTouches[0].screenY}},{key:"onEnd",value:function onEnd(a){this.coords.endX=a.changedTouches[0].screenX,this.coords.endY=a.changedTouches[0].screenY,this.dispatch()}},{key:"bind",value:function bind(){this.element.addEventListener("touchstart",this.onStart,!1),this.element.addEventListener("touchend",this.onEnd,!1)}},{key:"unbind",value:function unbind(){this.element.removeEventListener("touchstart",this.onStart,!1),this.element.removeEventListener("touchend",this.onEnd,!1)}},{key:"getEventName",value:function getEventName(){var a=Math.abs,b=this.threshold,c=this.coords,d=c.startX,e=c.startY,f=c.endX,g=c.endY;return f<d&&a(f-d)>b?"swipeleft":f>d&&a(f-d)>b?"swiperight":g<e&&a(g-e)>b?"swipeup":g>e&&a(g-e)>b?"swipedown":g===e&&f===d?"tap":""}},{key:"dispatch",value:function dispatch(){var a=this.getEventName();if(a){// TODO: Check browser support
var b=new CustomEvent(a,{detail:this.eventData});this.element.dispatchEvent(b)}}}]),a}();a["default"]=e});
(function(a,b){if("function"==typeof define&&define.amd)define(["exports"],b);else if("undefined"!=typeof exports)b(exports);else{var c={exports:{}};b(c.exports),a.touchsweep=c.exports}})("undefined"==typeof globalThis?"undefined"==typeof self?this:self:globalThis,function(a){"use strict";function b(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function c(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function d(a,b,d){return b&&c(a.prototype,b),d&&c(a,d),a}Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=void 0;var e=/*#__PURE__*/function(){/**
* Create a new TouchSweep instance
* @constructor
* @param {HTMLElement} element
* @param {any} data
* @param {number} threshold
* @return {TouchSweep}
*/function a(){var c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:document.body,d=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:40;return b(this,a),this.element=c,this.eventData=d,this.threshold=e,this.coords={startX:0,startY:0,endX:0,endY:0},this.onStart=this.onStart.bind(this),this.onEnd=this.onEnd.bind(this),this.bind(),this}return d(a,[{key:"onStart",value:function onStart(a){this.coords.startX=a.changedTouches[0].screenX,this.coords.startY=a.changedTouches[0].screenY}},{key:"onEnd",value:function onEnd(a){this.coords.endX=a.changedTouches[0].screenX,this.coords.endY=a.changedTouches[0].screenY,this.dispatch()}},{key:"bind",value:function bind(){this.element.addEventListener("touchstart",this.onStart,!1),this.element.addEventListener("touchend",this.onEnd,!1)}},{key:"unbind",value:function unbind(){this.element.removeEventListener("touchstart",this.onStart,!1),this.element.removeEventListener("touchend",this.onEnd,!1)}},{key:"getEventName",value:function getEventName(){var a=Math.abs,b=this.threshold,c=this.coords,d=c.startX,e=c.startY,f=c.endX,g=c.endY;return f<d&&a(f-d)>b?"swipeleft":f>d&&a(f-d)>b?"swiperight":g<e&&a(g-e)>b?"swipeup":g>e&&a(g-e)>b?"swipedown":g===e&&f===d?"tap":""}},{key:"dispatch",value:function dispatch(){var a=this.getEventName();if(a){var b=new CustomEvent(a,{detail:this.eventData});this.element.dispatchEvent(b)}}}]),a}();a["default"]=e});
{
"name": "touchsweep",
"version": "1.1.0",
"version": "1.2.0",
"description": "Super tiny vanilla JS module to detect swipe direction",

@@ -15,6 +15,8 @@ "keywords": [

"main": "dist/touchsweep.js",
"types": "dist/touchsweep.d.ts",
"scripts": {
"dist": "babel src/touchsweep.js --out-file dist/touchsweep.js",
"minify": "babel src/touchsweep.js --out-file dist/touchsweep.min.js --presets minify,@babel/env",
"build": "npm run dist && npm run minify"
"types": "tsc",
"build": "yarn dist && yarn minify && yarn tsc"
},

@@ -29,19 +31,10 @@ "repository": "git@github.com:scriptex/touchsweep.git",

"devDependencies": {
"@babel/cli": "7.10.1",
"@babel/core": "7.10.2",
"@babel/plugin-proposal-class-properties": "7.10.1",
"@babel/plugin-proposal-decorators": "7.10.1",
"@babel/plugin-proposal-export-namespace-from": "7.10.1",
"@babel/plugin-proposal-function-sent": "7.10.1",
"@babel/plugin-proposal-json-strings": "7.10.1",
"@babel/plugin-proposal-numeric-separator": "7.10.1",
"@babel/plugin-proposal-throw-expressions": "7.10.1",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
"@babel/plugin-syntax-import-meta": "7.10.1",
"@babel/plugin-transform-modules-umd": "7.10.1",
"@babel/preset-env": "7.10.2",
"babel-loader": "8.1.0",
"babel-minify": "0.5.1"
"@babel/cli": "7.13.14",
"@babel/core": "7.13.15",
"@babel/plugin-transform-modules-umd": "7.13.0",
"@babel/preset-env": "7.13.15",
"babel-minify": "0.5.1",
"typescript": "4.2.4"
},
"dependencies": {}
}

@@ -5,3 +5,3 @@ [![GitHub release](https://img.shields.io/github/release/scriptex/touchsweep.svg)](https://github.com/scriptex/touchsweep/releases/latest)

[![Github file size](https://img.shields.io/github/size/scriptex/touchsweep/dist/touchsweep.min.js.svg)](https://github.com/scriptex/touchsweep)
[![Build Status](https://travis-ci.org/scriptex/touchsweep.svg?branch=master)](https://travis-ci.org/scriptex/touchsweep)
[![Build Status](https://travis-ci.com/scriptex/touchsweep.svg?branch=master)](https://travis-ci.com/scriptex/touchsweep)
[![npm](https://img.shields.io/npm/dt/touchsweep.svg)](https://www.npmjs.com/package/touchsweep)

@@ -99,4 +99,10 @@ [![npm](https://img.shields.io/npm/v/touchsweep.svg)](https://www.npmjs.com/package/touchsweep)

## Support this project
[![Tweet](https://img.shields.io/badge/Tweet-Share_this_repository-blue.svg?style=flat-square&logo=twitter&color=38A1F3)](https://twitter.com/intent/tweet?text=Checkout%20this%20awesome%20software%20project%3A&url=https%3A%2F%2Fgithub.com%2Fscriptex%2Ftouchsweep&via=scriptexbg&hashtags=software%2Cgithub%2Ccode%2Cawesome)
[![Donate](https://img.shields.io/badge/Donate-Support_me_on_PayPal-blue.svg?style=flat-square&logo=paypal&color=222d65)](https://www.paypal.me/scriptex)
[![Become a Patron](https://img.shields.io/badge/Become_Patron-Support_me_on_Patreon-blue.svg?style=flat-square&logo=patreon&color=e64413)](https://www.patreon.com/atanas)
## LICENSE
MIT
export default class TouchSweep {
/**
* Create a new TouchSweep instance
* @constructor
* @param {HTMLElement} element
* @param {any} data
* @param {number} threshold
* @return {TouchSweep}
*/
constructor(element = document.body, data = {}, threshold = 40) {

@@ -77,3 +85,2 @@ this.element = element;

// TODO: Check browser support
const event = new CustomEvent(eventName, {

@@ -80,0 +87,0 @@ detail: this.eventData

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