https://github.com/ranjeetsinghbnl/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.
https://github.com/ranjeetsinghbnl/s-swipe
stencil-components stenciljs swipe-gestures typescript webcomponent
Last synced: 2 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/ranjeetsinghbnl/s-swipe
- Owner: ranjeetsinghbnl
- License: mit
- Created: 2020-02-09T09:52:15.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-09T10:02:53.000Z (over 6 years ago)
- Last Synced: 2025-03-14T23:29:03.639Z (over 1 year ago)
- Topics: stencil-components, stenciljs, swipe-gestures, typescript, webcomponent
- Language: TypeScript
- Size: 7.81 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README

# ``
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
```html
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.
```
For more guides on stencil.js components, please [check](https://stenciljs.com/docs/component) their documentation.
## Getting Started
To start building a new web component using Stencil, clone this repo to a new directory:
```bash
git clone https://github.com/ranjeetsinghbnl/s-swipe.git s-swipe
cd s-swipe
git remote rm origin
```
and run:
```bash
npm install
npm start
```
To build the component for production, run:
```bash
npm run build
```
To run the unit tests for the components, run:
```bash
npm test
```
## Using this component
### Script tag
- [Publish to NPM](https://docs.npmjs.com/getting-started/publishing-npm-packages)
- Put a script tag similar to this `` 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 `` 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](https://stenciljs.com/docs/javascript).
## 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` |
```javascript
interface ISwipeEvent {
up: boolean;
down: boolean;
left: boolean;
right: boolean;
}
```
## Events
| Event | Description | Type |
| -------- | ----------- | -------------------------- |
| `sSwipe` | | `CustomEvent` |