Skip to content

Stencil Swipe Component is a simple component that detects finger swipe events on touch devices and trigger custom events as you swiped-left, swiped-right, swiped-up and swiped-down on an element.

License

Notifications You must be signed in to change notification settings

ranjeetsinghbnl/s-swipe

Repository files navigation

Built With Stencil

<s-swipe/>

Stencil Swipe Component is a simple component that detects finger swipe events on touch devices and trigger custom events as you swiped-left, swiped-right, swiped-up and swiped-down on an element.

You can detect swipe on any html element easily

<s-swipe
threshold-x="100"  
threshold-y="30"  
time-threshold="30"
>
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
    standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a
    type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting,
    remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
    Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of
    Lorem Ipsum.
</s-swipe>

For more guides on stencil.js components, please check their documentation.

Getting Started

To start building a new web component using Stencil, clone this repo to a new directory:

git clone https://github.com/ranjeetsinghbnl/s-swipe.git s-swipe
cd s-swipe
git remote rm origin

and run:

npm install
npm start

To build the component for production, run:

npm run build

To run the unit tests for the components, run:

npm test

Using this component

Script tag

  • Publish to NPM
  • Put a script tag similar to this <script src='https://unpkg.com/s-swipe@0.0.1/dist/s-swipe.js'></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc

Node Modules

  • Run npm install s-swipe --save
  • Put a script tag similar to this <script src='node_modules/s-swipe/dist/s-swipe.js'></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc

In a stencil-starter app

  • Run npm install s-swipe --save
  • Add an import to the npm packages import s-swipe;
  • Then you can use the element anywhere in your template, JSX, html etc

For more details you can also check the official integration guide.

Properties

Property Attribute Description Type Default
thresholdX threshold-x x axis threshold number 30
thresholdY threshold-y y axis threshold number 30
timeThreshold time-threshold time threshold number 100
interface ISwipeEvent {
  up: boolean;
  down: boolean;
  left: boolean;
  right: boolean;
}

Events

Event Description Type
sSwipe CustomEvent<ISwipeEvent>

About

Stencil Swipe Component is a simple component that detects finger swipe events on touch devices and trigger custom events as you swiped-left, swiped-right, swiped-up and swiped-down on an element.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published