New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

alpinejs-swipe

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

alpinejs-swipe

AlpineJS custom directive to detect swipe gestures on an element.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
733
decreased by-12.63%
Maintainers
1
Weekly downloads
 
Created
Source

alpinejs-swipe

AlpineJS custom directive to detect swipe gestures on an element.

npm npm bundle size Module system

Installation

CDN

Include the following <script> tag in the <head> of your document:

<script src="https://unpkg.com/alpinejs-swipe"></script>

Important: This must be added before loading Alpine.js when using CDN links.

NPM

You can also install using a package manager.

npm install alpinejs-swipe
yarn add alpinejs-swipe

And then register the plugin before Alpine.start():

import swipePlugin from "alpinejs-swipe";
Alpine.plugin(swipePlugin);
Alpine.start();

Usage

Just use the "x-swipe" directive with an expression and you'll be called back when the user swipes in the direction you want.

<div x-swipe:down="console.log('SWIPED DOWN!')"></div>
<div x-swipe:right="console.log('SWIPED RIGHT!')"></div>

You can also define a threshold with modifiers:

<div x-swipe:down.threshold.200px="console.log('SWIPED DOWN!')"></div>

The default threshold is 50.

If you want, it's also possible to be called back when the user swipes to any side, just omit the direction:

<div x-swipe="console.log('SWIPED!')"></div>

In this case the direction will be passed to the function in the expression through the first argument.

Future ideas

License

Licensed under the MIT license, see LICENSE.md for details.

FAQs

Package last updated on 21 Feb 2023

Did you know?

Socket

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.

Install

Related posts

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