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

vanilla-swipe

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vanilla-swipe - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

lib/utils/calculateDuration.d.ts

1

lib/index.d.ts

@@ -19,2 +19,3 @@ import { State, ConstructorProps } from './types';

duration: number;
velocity: number;
};

@@ -21,0 +22,0 @@ handleSwipeStart(e: any): void;

@@ -8,2 +8,3 @@ export declare function calculatePosition(prevPos: prevPosition, nextPos: nextPosition): Value;

duration: number;
velocity: number;
};

@@ -10,0 +11,0 @@ declare type prevPosition = {

10

lib/utils/calculatePosition.js

@@ -8,2 +8,6 @@ "use strict";

var _calculateDuration = require("./calculateDuration");
var _calculateVelocity = require("./calculateVelocity");
function calculatePosition(prevPos, nextPos) {

@@ -14,3 +18,4 @@ var deltaX = prevPos.x - nextPos.x;

var absY = Math.abs(deltaY);
var duration = Date.now() - prevPos.start;
var duration = (0, _calculateDuration.calculateDuration)(prevPos.start, Date.now());
var velocity = (0, _calculateVelocity.calculateVelocity)(absX, absY, duration);
return {

@@ -21,4 +26,5 @@ deltaX: deltaX,

absY: absY,
duration: duration
duration: duration,
velocity: velocity
};
}

@@ -1,9 +0,11 @@

export * from './getInitialState';
export * from './getInitialProps';
export * from './checkIsPassiveSupported';
export * from './calculatePosition';
export * from './calculateMovingPosition';
export * from './rotateByAngle';
export * from './checkIsMoreThanSingleTouches';
export * from './createOptions';
export * from './getOptions';
export * from "./getInitialState";
export * from "./getInitialProps";
export * from "./checkIsPassiveSupported";
export * from "./calculateDuration";
export * from "./calculatePosition";
export * from "./calculateMovingPosition";
export * from "./calculateVelocity";
export * from "./rotateByAngle";
export * from "./checkIsMoreThanSingleTouches";
export * from "./createOptions";
export * from "./getOptions";

@@ -43,2 +43,14 @@ "use strict";

var _calculateDuration = require("./calculateDuration");
Object.keys(_calculateDuration).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _calculateDuration[key];
}
});
});
var _calculatePosition = require("./calculatePosition");

@@ -68,2 +80,14 @@

var _calculateVelocity = require("./calculateVelocity");
Object.keys(_calculateVelocity).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _calculateVelocity[key];
}
});
});
var _rotateByAngle = require("./rotateByAngle");

@@ -70,0 +94,0 @@

{
"name": "vanilla-swipe",
"version": "1.0.0",
"version": "1.1.0",
"description": "Tiny vanilla JS library to detect swipe direction.",

@@ -12,3 +12,3 @@ "main": "lib/index.js",

"type-check:watch": "npm run type-check -- --watch",
"build": "rimraf lib && npm run build:types && npm run build:js",
"build": "rimraf lib && rimraf coverage && npm run build:types && npm run build:js",
"build:types": "tsc --emitDeclarationOnly",

@@ -15,0 +15,0 @@ "build:js": "babel src --out-dir lib --extensions \".ts,.tsx\"",

@@ -7,3 +7,3 @@ # vanilla-swipe

[![npm version](https://badge.fury.io/js/vanilla-swipe.svg)](https://img.shields.io/badge/coverage-100%25-brightgreen)
![covarage](https://img.shields.io/badge/coverage-100%25-brightgreen)
[![covarage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://img.shields.io/badge/coverage-100%25-brightgreen)

@@ -14,5 +14,5 @@ ### Types

type ConstructorProps = {
element: HTMLElement | null;
rotationAngle: number | 0;
delta: number | 10; // minimum distance to the start of the swiping (px)
element?: HTMLElement | null;
rotationAngle?: number | 0;
delta?: number | 10; // minimum distance to the start of the swiping (px)
mouseTrackingEnabled?: boolean | false;

@@ -27,3 +27,11 @@ touchTrackingEnabled?: boolean | true;

type EventHandler = {
(e: Event, deltaX: number, deltaY: number, absX: number, absY: number, duration: number): void;
(
e: Event,
deltaX: number,
deltaY: number,
absX: number,
absY: number,
duration: number,
velocity: number
): void;
};

@@ -59,3 +67,3 @@ ```

function handler() {
console.log(...arguments); // -> Event, deltaX, deltaY, absX, absY, duration
console.log(...arguments); // -> Event, deltaX, deltaY, absX, absY, duration, velocity
}

@@ -62,0 +70,0 @@ ```

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