# @dreamworld/dw-swipe

> A LitElement mixin to implement Swipe behavior. e.g. It's used in Kerika board to scroll column one at a time through swipe gesture.

Latest version **2.0.0** (published 2022-10-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install @dreamworld/dw-swipe
pnpm add @dreamworld/dw-swipe
yarn add @dreamworld/dw-swipe
bun add @dreamworld/dw-swipe
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2022-10-19 |
| First published | 2019-11-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 31.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | chiragmoradiya, chetang7, ajay-dhameliya, dw-devops |

## Links

- npm: https://www.npmjs.com/package/@dreamworld/dw-swipe
- Repository: https://github.com/DreamworldSolutions/dw-swipe
- Homepage: https://github.com/DreamworldSolutions/dw-swipe#readme
- Issues: https://github.com/DreamworldSolutions/dw-swipe/issues
- npm.io page: https://npm.io/package/@dreamworld/dw-swipe

## Dependencies (2)

- [reselect](https://npm.io/package/reselect.md) ^4.0.0
- [@dreamworld/pwa-helpers](https://npm.io/package/@dreamworld/pwa-helpers.md) ^1.14.0

## Recent versions

- 2.0.0 (latest) — 2022-10-19
- 2.0.0-upgrade-to-lit.1 (upgrade-to-lit) — 2022-10-19
- 1.2.2-warn-when-no-element-found.1 (warn-when-no-element-found) — 2021-03-23
- 1.2.0-return-swipe-possible-value-on-swipe-next-prev.3 (return-swipe-possible-value-on-swipe-next-prev) — 2020-12-08
- 1.1.8-update-config.1 (update-config) — 2020-10-26
- 1.1.7-formatting.1 (formatting) — 2020-09-16
- 1.1.7-revert-isconnected.1 (revert-isconnected) — 2020-09-16
- 1.1.5-set-property-after-connected.1 (set-property-after-connected) — 2020-08-28
- 1.1.4-solve-performance-issue.1 (solve-performance-issue) — 2020-07-31
- 1.1.0-kerika-test.1 (kerika-test) — 2020-03-18
- 1.0.7-issue-wrong-slide-swipe.2 (issue-wrong-slide-swipe) — 2020-03-18
- 1.0.7-swipe-is-not-working-in-firefox-browser.1 (swipe-is-not-working-in-firefox-browser) — 2020-03-18
- 1.1.0-provide-swipe-scroll-method.5 (provide-swipe-scroll-method) — 2020-03-13
- 1.0.5-enhance-swipe-behavior-to-allow-quick-swiping.1 (enhance-swipe-behavior-to-allow-quick-swiping) — 2020-01-17
- 1.0.5-provide-a-way-to-disable-animation-using-scroll-to-index-method.1 (provide-a-way-to-disable-animation-using-scroll-to-index-method) — 2019-12-17
- … 41 more at https://npm.io/package/@dreamworld/dw-swipe/versions

## README

# dw-swipe
A LitElement mixin to implement Swipe behavior. e.g. It's used in Kerika board to scroll column one at a time through swipe gesture.


## Installation

```html
npm install @dreamworld/dw-swipe
```

## Usage

1. Apply Mixin to your view-element Class.
```js
//Import dw -swiper mixin
@import {DwSwipe} from '@dreamworld/dw-swipe';
	
//Import lit-element class
@import {LitElement} . from 'lit-element';
	
//Extend dw-swipe class to lit-element class
class swiperList extends DwSwipe(LitElement) {}
```

2. Set required layout in your view-element template.
e.g. 
```html
<!-- Slider main container -->  
<div class="dw-swipe-container">  
	<!-- Additional required slider wrapper -->  
	<div class="dw-swipe-slider-frame">  
		<!-- Slides -->  
		<div>Slide 1</div>  
		<div>Slide 2</div>  
		<div >Slide 3</div> ... 
  </div>
</div>
```

3. Set fix width/height to the `.dw-swipe-container`.
```css
.dw-swipe-container {  
	width: 600px;  
	height: 300px;  
}
```

## Slider Methods & Properties
### Properties
| Name | Type | Default |  Description |
| :------- | ----: | :---: |  :---: |
| swipeDisabled | Boolean | false | Swipe is disabled or not |
| swipeDirection | String | horizontal | Could be 'horizontal' or 'vertical' (for vertical slider). |
| swipeMinDisplacement | Number | 25 | Number of pixels. If total movement (mouse or touch) is less than this number, than it won't be considered a swipe event and at the end scroll will be restored to the start position. |
| swipeRestraint | Number | 25 | Number of pixels. Actual move/scroll operation will be started only when user moves (mouse or touch) by these many pixels. |
| swipeMultiplier | Number | 1 | How many slides are a move to next/previous?|

### Methods
| Name | Description |  
| :------- | ----: |  
| _swipeRestore() | Restore swipe to current slide |
| _swipeNext() | Swipe to next slide |
| _swipePrev() | Swipe to previous slide |
| _swipeScrollToPosition(pos) | Swipe to specific position. **pos**: Passed to   swipe position |
| _swipeScrollToIndex(index, disableTransition) | Swipe to specific Slide (identified by the 0-based index.).|
| _swipeDestroy() | Destroy a swipe |

---
_Source: https://npm.io/package/@dreamworld/dw-swipe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
