
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
vanilla-swipe
Advanced tools
Tiny vanilla JS library to detect swipe direction.
type ConstructorProps = {
element?: HTMLElement | null;
target?: HTMLElement | null;
delta?: number | 10;
directionDelta?: number | 0;
rotationAngle?: number | 0;
mouseTrackingEnabled?: boolean | false;
touchTrackingEnabled?: boolean | true;
preventDefaultTouchmoveEvent?: boolean | false;
preventTrackingOnMouseleave?: boolean | false;
onSwipeStart?: EventHandler;
onSwiping?: EventHandler;
onSwiped?: EventHandler;
onTap?: EventHandler;
};
type EventHandler = {
(e: Event, data: EventData): void;
};
type EventData = {
absX: number;
absY: number;
deltaX: number;
deltaY: number;
directionX: 'LEFT' | 'RIGHT' | 'NONE';
directionY: 'TOP' | 'BOTTOM' | 'NONE';
duration: number; // ms
velocity: number; // (px/ms)
};
element
- target event triggertarget
- additionally target event trigger, if specified with the element, will be used by all handlers to trigger the actiondelta
- minimal distance in px
before a swipe startsdirectionDelta
- minimum distance in px
required for the direction to be reversed while swiping.rotationAngle
- rotation anglemouseTrackingEnabled
- enable mouse trackingtouchTrackingEnabled
- enable touch trackingpreventDefaultTouchmoveEvent
- prevent default touch events while touchingpreventTrackingOnMouseleave
- triggered onSwiped
callback when the event loses the element's focusonSwipeStart
- triggered on swipe start (if the delta
is passed)onSwiping
- triggered during swipeonSwiped
- triggered after swipeonTap
- triggered when the swipe value is less than the minimum distance (delta
)init(): void
update(options: ConstructorProps): void
destroy(): void
isTouchEventsSupported(): boolean
npm install vanilla-swipe
import VanillaSwipe from 'vanilla-swipe';
const isTouchEventsSupported = VanillaSwipe.isTouchEventsSupported();
const VS = new VanillaSwipe({
element: document.getElementById('some-id'),
onSwiping: handler,
onSwiped: handler,
mouseTrackingEnabled: true,
});
VS.init();
function handler() {
console.log(...arguments); // -> Event, EventData
}
npm i
npm start
npm test
npm run test:coverage
FAQs
Tiny vanilla JS library to detect swipe direction.
The npm package vanilla-swipe receives a total of 35,167 weekly downloads. As such, vanilla-swipe popularity was classified as popular.
We found that vanilla-swipe demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.