4.3.7 • Published 10 months ago
@kolserdav/swiper v4.3.7
swiper
Simple and powerfull dynamic react swiper component
Install
npm install --save @kolserdav/swiper
Usage
import React, { useState, useEffect } from 'react';
import { Swiper, GetSwipeHandler, Swipe } from '@kolserdav/swiper';
import '@kolserdav/swiper/dist/styles.css';
const COUNT = 4;
const getNext: GetSwipeHandler = async (old) => {
let id = old + 1;
id = id <= COUNT ? id : 0;
return {
id,
children: <h1>Test {id}</h1>,
};
};
const getPrevios: GetSwipeHandler = async (old) => {
let id = old - 1;
id = id >= 0 ? id : COUNT;
return {
id,
children: <h1>Test {id}</h1>,
};
};
const App = (): React.ReactElement => {
const [current, setCurrent] = useState<Swipe>();
useEffect(() => {
if (!current) {
(async () => {
setCurrent(await getNext(0));
})();
}
}, []);
return (
<div>
{current && (
<Swiper
defaultCurrent={current}
getNext={getNext}
getPrev={getPrevios}
invitationAnimation={true}
durationAnimation={1000}
/>
)}
</div>
);
};
export default App;
Properties
interface SwiperProps {
/**
* Current card content
*/
defaultCurrent: Swipe;
/**
* Get next card handler
*/
getNext: GetSwipeHandler;
/**
* Get previous card handler
*/
getPrev: GetSwipeHandler;
/**
* Class name for content block
*/
className?: string;
/**
* invitation animation
*/
invitationAnimation?: boolean;
/**
* On swipe callback
*/
onSwipe?: (currentId: number) => void;
/**
* Auto slide if provieded
*/
durationAnimation?: number;
/**
* Blocked swipe event
*/
blockSwipe?: boolean;
/**
* Show dots
*/
dots?: {
inactive: boolean;
list: number[];
active: number;
};
/**
* Makes dark colors as light
*/
darkTheme?: boolean;
}
License
MIT © kolserdav
4.3.7
10 months ago
4.3.6
10 months ago
4.3.5
10 months ago
4.3.2
10 months ago
4.3.1
10 months ago
4.3.4
10 months ago
4.3.3
10 months ago
4.3.0
10 months ago
4.2.2
2 years ago
4.2.1
3 years ago
4.2.0
3 years ago
4.1.5
3 years ago
3.0.3
3 years ago
3.0.2
3 years ago
3.0.1
3 years ago
3.0.0
3 years ago
4.1.4
3 years ago
4.1.3
3 years ago
4.1.0
3 years ago
4.0.1
3 years ago
4.0.0
3 years ago
4.1.2
3 years ago
4.0.3
3 years ago
4.1.1
3 years ago
4.0.2
3 years ago
2.3.1
3 years ago
2.3.0
3 years ago
2.2.3
3 years ago
2.2.2
3 years ago
2.2.0-alfa
4 years ago
2.1.3-beta
4 years ago
2.1.2-beta
4 years ago
2.1.1-beta
4 years ago
2.1.0-beta
4 years ago
2.0.1-beta
4 years ago
2.0.0-beta
4 years ago
1.0.10
4 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago