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

react-swipeable

Package Overview
Dependencies
Maintainers
25
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-swipeable - npm Package Compare versions

Comparing version 7.0.0-alpha.2 to 7.0.0-alpha.3

12

dist/react-swipeable.js

@@ -56,12 +56,13 @@ (function (global, factory) {

const onStart = (event) => {
const isTouch = "touches" in event;
// if more than a single touch don't track, for now...
if (event && "touches" in event && event.touches.length > 1)
if (isTouch && event.touches.length > 1)
return;
set((state, props) => {
// setup mouse listeners on document to track swipe since swipe can leave container
if (props.trackMouse) {
if (props.trackMouse && !isTouch) {
document.addEventListener(mouseMove, onMove);
document.addEventListener(mouseUp, onUp);
}
const { clientX, clientY } = "touches" in event ? event.touches[0] : event;
const { clientX, clientY } = isTouch ? event.touches[0] : event;
const xy = rotateXYByAngle([clientX, clientY], props.rotationAngle);

@@ -75,5 +76,6 @@ props.onTouchStartOrOnMouseDown &&

set((state, props) => {
const isTouch = "touches" in event;
// Discount a swipe if additional touches are present after
// a swipe has started.
if ("touches" in event && event.touches.length > 1) {
if (isTouch && event.touches.length > 1) {
return state;

@@ -85,3 +87,3 @@ }

}
const { clientX, clientY } = "touches" in event ? event.touches[0] : event;
const { clientX, clientY } = isTouch ? event.touches[0] : event;
const [x, y] = rotateXYByAngle([clientX, clientY], props.rotationAngle);

@@ -88,0 +90,0 @@ const deltaX = x - state.xy[0];

@@ -52,12 +52,13 @@ import * as React from 'react';

const onStart = (event) => {
const isTouch = "touches" in event;
// if more than a single touch don't track, for now...
if (event && "touches" in event && event.touches.length > 1)
if (isTouch && event.touches.length > 1)
return;
set((state, props) => {
// setup mouse listeners on document to track swipe since swipe can leave container
if (props.trackMouse) {
if (props.trackMouse && !isTouch) {
document.addEventListener(mouseMove, onMove);
document.addEventListener(mouseUp, onUp);
}
const { clientX, clientY } = "touches" in event ? event.touches[0] : event;
const { clientX, clientY } = isTouch ? event.touches[0] : event;
const xy = rotateXYByAngle([clientX, clientY], props.rotationAngle);

@@ -71,5 +72,6 @@ props.onTouchStartOrOnMouseDown &&

set((state, props) => {
const isTouch = "touches" in event;
// Discount a swipe if additional touches are present after
// a swipe has started.
if ("touches" in event && event.touches.length > 1) {
if (isTouch && event.touches.length > 1) {
return state;

@@ -81,3 +83,3 @@ }

}
const { clientX, clientY } = "touches" in event ? event.touches[0] : event;
const { clientX, clientY } = isTouch ? event.touches[0] : event;
const [x, y] = rotateXYByAngle([clientX, clientY], props.rotationAngle);

@@ -84,0 +86,0 @@ const deltaX = x - state.xy[0];

@@ -56,12 +56,13 @@ 'use strict';

const onStart = (event) => {
const isTouch = "touches" in event;
// if more than a single touch don't track, for now...
if (event && "touches" in event && event.touches.length > 1)
if (isTouch && event.touches.length > 1)
return;
set((state, props) => {
// setup mouse listeners on document to track swipe since swipe can leave container
if (props.trackMouse) {
if (props.trackMouse && !isTouch) {
document.addEventListener(mouseMove, onMove);
document.addEventListener(mouseUp, onUp);
}
const { clientX, clientY } = "touches" in event ? event.touches[0] : event;
const { clientX, clientY } = isTouch ? event.touches[0] : event;
const xy = rotateXYByAngle([clientX, clientY], props.rotationAngle);

@@ -75,5 +76,6 @@ props.onTouchStartOrOnMouseDown &&

set((state, props) => {
const isTouch = "touches" in event;
// Discount a swipe if additional touches are present after
// a swipe has started.
if ("touches" in event && event.touches.length > 1) {
if (isTouch && event.touches.length > 1) {
return state;

@@ -85,3 +87,3 @@ }

}
const { clientX, clientY } = "touches" in event ? event.touches[0] : event;
const { clientX, clientY } = isTouch ? event.touches[0] : event;
const [x, y] = rotateXYByAngle([clientX, clientY], props.rotationAngle);

@@ -88,0 +90,0 @@ const deltaX = x - state.xy[0];

{
"name": "react-swipeable",
"version": "7.0.0-alpha.2",
"version": "7.0.0-alpha.3",
"description": "React Swipe event handler hook",

@@ -36,11 +36,11 @@ "source": "./src/index.ts",

{
"limit": "1.675 KB",
"limit": "1.7 KB",
"path": "lib/index.js"
},
{
"limit": "1.75 KB",
"limit": "1.8 KB",
"path": "dist/react-swipeable.js"
},
{
"limit": "1.75 KB",
"limit": "1.8 KB",
"path": "es/index.js"

@@ -92,4 +92,4 @@ }

"@types/react-dom": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^4.14.0",
"@typescript-eslint/parser": "^4.14.0",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"coveralls": "^3.0.3",

@@ -109,3 +109,3 @@ "eslint": "^7.18.0",

"ts-jest": "^27.1.4",
"typescript": "^4.1.3"
"typescript": "^4.6.3"
},

@@ -112,0 +112,0 @@ "dependencies": {},

@@ -99,13 +99,13 @@ /* global document */

const onStart = (event: HandledEvents) => {
const isTouch = "touches" in event;
// if more than a single touch don't track, for now...
if (event && "touches" in event && event.touches.length > 1) return;
if (isTouch && event.touches.length > 1) return;
set((state, props) => {
// setup mouse listeners on document to track swipe since swipe can leave container
if (props.trackMouse) {
if (props.trackMouse && !isTouch) {
document.addEventListener(mouseMove, onMove);
document.addEventListener(mouseUp, onUp);
}
const { clientX, clientY } =
"touches" in event ? event.touches[0] : event;
const { clientX, clientY } = isTouch ? event.touches[0] : event;
const xy = rotateXYByAngle([clientX, clientY], props.rotationAngle);

@@ -128,5 +128,6 @@

set((state, props) => {
const isTouch = "touches" in event;
// Discount a swipe if additional touches are present after
// a swipe has started.
if ("touches" in event && event.touches.length > 1) {
if (isTouch && event.touches.length > 1) {
return state;

@@ -140,4 +141,3 @@ }

const { clientX, clientY } =
"touches" in event ? event.touches[0] : event;
const { clientX, clientY } = isTouch ? event.touches[0] : event;
const [x, y] = rotateXYByAngle([clientX, clientY], props.rotationAngle);

@@ -144,0 +144,0 @@ const deltaX = x - state.xy[0];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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