@kolserdav/swiper 4.1.4 → 4.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +124 -124
- package/dist/index.css +136 -136
- package/dist/index.d.ts +4 -0
- package/dist/index.js +35 -11
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +35 -12
- package/dist/index.modern.js.map +1 -1
- package/dist/navigate_next_black_24dp~NBZptwCk.svg +1 -0
- package/dist/navigate_next_black_24dp~kmANFsMv.svg +1 -0
- package/dist/navigate_next_black_48dp~bfNeNKBt.svg +1 -0
- package/dist/navigate_next_black_48dp~kmANFsMv.svg +1 -0
- package/package.json +93 -93
package/README.md
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
# swiper
|
|
2
|
-
|
|
3
|
-
> Simple and powerfull dynamic react swiper component
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/swiper) [](https://standardjs.com)
|
|
6
|
-
|
|
7
|
-
## Install
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install --save @kolserdav/swiper
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
```tsx
|
|
16
|
-
import React, { useState, useEffect } from 'react';
|
|
17
|
-
import { Swiper, GetSwipeHandler, Swipe } from '@kolserdav/swiper';
|
|
18
|
-
import '@kolserdav/swiper/dist/index.css'; // From version 3.0.0 is required
|
|
19
|
-
|
|
20
|
-
const COUNT = 4;
|
|
21
|
-
|
|
22
|
-
const getNext: GetSwipeHandler = async (old) => {
|
|
23
|
-
let id = old + 1;
|
|
24
|
-
id = id <= COUNT ? id : 0;
|
|
25
|
-
return {
|
|
26
|
-
id,
|
|
27
|
-
children: <h1>Test {id}</h1>,
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const getPrevios: GetSwipeHandler = async (old) => {
|
|
32
|
-
let id = old - 1;
|
|
33
|
-
id = id >= 0 ? id : COUNT;
|
|
34
|
-
return {
|
|
35
|
-
id,
|
|
36
|
-
children: <h1>Test {id}</h1>,
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const App = (): React.ReactElement => {
|
|
41
|
-
const [current, setCurrent] = useState<Swipe>();
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (!current) {
|
|
44
|
-
(async () => {
|
|
45
|
-
setCurrent(await getNext(0));
|
|
46
|
-
})();
|
|
47
|
-
}
|
|
48
|
-
}, []);
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<div>
|
|
52
|
-
{current && (
|
|
53
|
-
<Swiper
|
|
54
|
-
defaultCurrent={current}
|
|
55
|
-
getNext={getNext}
|
|
56
|
-
getPrev={getPrevios}
|
|
57
|
-
invitationAnimation={true}
|
|
58
|
-
durationAnimation={1000}
|
|
59
|
-
/>
|
|
60
|
-
)}
|
|
61
|
-
</div>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export default App;
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Properties
|
|
69
|
-
|
|
70
|
-
```tsx
|
|
71
|
-
interface SwiperProps {
|
|
72
|
-
/**
|
|
73
|
-
* Current card content
|
|
74
|
-
*/
|
|
75
|
-
defaultCurrent: Swipe;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Get next card handler
|
|
79
|
-
*/
|
|
80
|
-
getNext: GetSwipeHandler;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Get previous card handler
|
|
84
|
-
*/
|
|
85
|
-
getPrev: GetSwipeHandler;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Class name for content block
|
|
89
|
-
*/
|
|
90
|
-
className?: string;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* invitation animation
|
|
94
|
-
*/
|
|
95
|
-
invitationAnimation?: boolean;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* On swipe callback
|
|
99
|
-
*/
|
|
100
|
-
onSwipe?: (currentId: number) => void;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Auto slide if provieded
|
|
104
|
-
*/
|
|
105
|
-
durationAnimation?: number;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Blocked swipe event
|
|
109
|
-
*/
|
|
110
|
-
blockSwipe?: boolean;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Show dots
|
|
114
|
-
*/
|
|
115
|
-
dots?: {
|
|
116
|
-
list: number[];
|
|
117
|
-
active: number;
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## License
|
|
123
|
-
|
|
124
|
-
MIT © [kolserdav](https://github.com/kolserdav)
|
|
1
|
+
# swiper
|
|
2
|
+
|
|
3
|
+
> Simple and powerfull dynamic react swiper component
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/swiper) [](https://standardjs.com)
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install --save @kolserdav/swiper
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import React, { useState, useEffect } from 'react';
|
|
17
|
+
import { Swiper, GetSwipeHandler, Swipe } from '@kolserdav/swiper';
|
|
18
|
+
import '@kolserdav/swiper/dist/index.css'; // From version 3.0.0 is required
|
|
19
|
+
|
|
20
|
+
const COUNT = 4;
|
|
21
|
+
|
|
22
|
+
const getNext: GetSwipeHandler = async (old) => {
|
|
23
|
+
let id = old + 1;
|
|
24
|
+
id = id <= COUNT ? id : 0;
|
|
25
|
+
return {
|
|
26
|
+
id,
|
|
27
|
+
children: <h1>Test {id}</h1>,
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const getPrevios: GetSwipeHandler = async (old) => {
|
|
32
|
+
let id = old - 1;
|
|
33
|
+
id = id >= 0 ? id : COUNT;
|
|
34
|
+
return {
|
|
35
|
+
id,
|
|
36
|
+
children: <h1>Test {id}</h1>,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const App = (): React.ReactElement => {
|
|
41
|
+
const [current, setCurrent] = useState<Swipe>();
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (!current) {
|
|
44
|
+
(async () => {
|
|
45
|
+
setCurrent(await getNext(0));
|
|
46
|
+
})();
|
|
47
|
+
}
|
|
48
|
+
}, []);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div>
|
|
52
|
+
{current && (
|
|
53
|
+
<Swiper
|
|
54
|
+
defaultCurrent={current}
|
|
55
|
+
getNext={getNext}
|
|
56
|
+
getPrev={getPrevios}
|
|
57
|
+
invitationAnimation={true}
|
|
58
|
+
durationAnimation={1000}
|
|
59
|
+
/>
|
|
60
|
+
)}
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default App;
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Properties
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
interface SwiperProps {
|
|
72
|
+
/**
|
|
73
|
+
* Current card content
|
|
74
|
+
*/
|
|
75
|
+
defaultCurrent: Swipe;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Get next card handler
|
|
79
|
+
*/
|
|
80
|
+
getNext: GetSwipeHandler;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get previous card handler
|
|
84
|
+
*/
|
|
85
|
+
getPrev: GetSwipeHandler;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Class name for content block
|
|
89
|
+
*/
|
|
90
|
+
className?: string;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* invitation animation
|
|
94
|
+
*/
|
|
95
|
+
invitationAnimation?: boolean;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* On swipe callback
|
|
99
|
+
*/
|
|
100
|
+
onSwipe?: (currentId: number) => void;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Auto slide if provieded
|
|
104
|
+
*/
|
|
105
|
+
durationAnimation?: number;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Blocked swipe event
|
|
109
|
+
*/
|
|
110
|
+
blockSwipe?: boolean;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Show dots
|
|
114
|
+
*/
|
|
115
|
+
dots?: {
|
|
116
|
+
list: number[];
|
|
117
|
+
active: number;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT © [kolserdav](https://github.com/kolserdav)
|
package/dist/index.css
CHANGED
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
._1Lxpd {
|
|
2
|
-
position: relative;
|
|
3
|
-
overflow: hidden;
|
|
4
|
-
min-width: 320px;
|
|
5
|
-
width: 100%;
|
|
6
|
-
height: 100%;
|
|
7
|
-
min-height: 20vh;
|
|
8
|
-
max-width: 100vw;
|
|
9
|
-
display: flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
justify-content: center;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
._8Yd7S {
|
|
15
|
-
background-color: #fff;
|
|
16
|
-
border-radius: 1rem;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
._3uH2i {
|
|
20
|
-
position: relative;
|
|
21
|
-
width: 100%;
|
|
22
|
-
height: 100%;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
._xsi02 {
|
|
26
|
-
position: absolute;
|
|
27
|
-
max-width: inherit;
|
|
28
|
-
top: 0;
|
|
29
|
-
left: 0;
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
justify-content: center;
|
|
33
|
-
flex-direction: column;
|
|
34
|
-
}
|
|
35
|
-
._KqFRp {
|
|
36
|
-
left: -100%;
|
|
37
|
-
}
|
|
38
|
-
._1uQwZ {
|
|
39
|
-
left: 100%;
|
|
40
|
-
}
|
|
41
|
-
._18Pcq {
|
|
42
|
-
transition: left 0.4s ease-in 0s;
|
|
43
|
-
}
|
|
44
|
-
._1nj1b {
|
|
45
|
-
transition: left 0.4s ease-out 0s;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
._3cLUl {
|
|
49
|
-
width: 100%;
|
|
50
|
-
height: 100%;
|
|
51
|
-
position: relative;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
._2jwZj {
|
|
55
|
-
border-radius: 2px;
|
|
56
|
-
position: relative;
|
|
57
|
-
width: calc(100% - 48px);
|
|
58
|
-
height: calc(100% - 48px);
|
|
59
|
-
box-shadow: 0px 0px 5px 1px rgba(34, 60, 80, 0.14);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
._2hTXI {
|
|
63
|
-
cursor: pointer;
|
|
64
|
-
position: absolute;
|
|
65
|
-
width: auto;
|
|
66
|
-
height: auto;
|
|
67
|
-
display: flex;
|
|
68
|
-
align-items: center;
|
|
69
|
-
z-index: 12;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
._2Z7EZ {
|
|
73
|
-
right: 0;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
._2Xedt {
|
|
77
|
-
left: 0;
|
|
78
|
-
transform: rotate(180deg);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
._2J4XS {
|
|
82
|
-
display: inline-flex;
|
|
83
|
-
align-items: center;
|
|
84
|
-
justify-content: center;
|
|
85
|
-
position: relative;
|
|
86
|
-
box-sizing: border-box;
|
|
87
|
-
background-color: transparent;
|
|
88
|
-
outline: 0;
|
|
89
|
-
border: 0;
|
|
90
|
-
margin: 0;
|
|
91
|
-
border-radius: 0;
|
|
92
|
-
padding: 0;
|
|
93
|
-
cursor: pointer;
|
|
94
|
-
-webkit-user-select: none;
|
|
95
|
-
-moz-user-select: none;
|
|
96
|
-
-ms-user-select: none;
|
|
97
|
-
user-select: none;
|
|
98
|
-
vertical-align: middle;
|
|
99
|
-
text-decoration: none;
|
|
100
|
-
color: inherit;
|
|
101
|
-
text-align: center;
|
|
102
|
-
flex: 0 0 auto;
|
|
103
|
-
font-size: 1.5rem;
|
|
104
|
-
padding: 8px;
|
|
105
|
-
border-radius: 50%;
|
|
106
|
-
overflow: visible;
|
|
107
|
-
color: rgba(0, 0, 0, 0.54);
|
|
108
|
-
transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
109
|
-
}
|
|
110
|
-
._2J4XS:hover {
|
|
111
|
-
background-color: rgba(0, 0, 0, 0.054);
|
|
112
|
-
}
|
|
113
|
-
._2J4XS:active {
|
|
114
|
-
background-color: rgba(0, 0, 0, 0.007);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
._3MuXE {
|
|
118
|
-
position: absolute;
|
|
119
|
-
display: flex;
|
|
120
|
-
flex-direction: row;
|
|
121
|
-
bottom: 0;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
._3U2py {
|
|
125
|
-
cursor: pointer;
|
|
126
|
-
position: relative;
|
|
127
|
-
width: 8px;
|
|
128
|
-
height: 8px;
|
|
129
|
-
margin: 2px;
|
|
130
|
-
border: 1px solid gray;
|
|
131
|
-
border-radius: 50%;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
._3U2py._3sodH {
|
|
135
|
-
cursor: default;
|
|
136
|
-
background-color: gray;
|
|
1
|
+
._1Lxpd {
|
|
2
|
+
position: relative;
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
min-width: 320px;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
min-height: 20vh;
|
|
8
|
+
max-width: 100vw;
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
._8Yd7S {
|
|
15
|
+
background-color: #fff;
|
|
16
|
+
border-radius: 1rem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
._3uH2i {
|
|
20
|
+
position: relative;
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
._xsi02 {
|
|
26
|
+
position: absolute;
|
|
27
|
+
max-width: inherit;
|
|
28
|
+
top: 0;
|
|
29
|
+
left: 0;
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
}
|
|
35
|
+
._KqFRp {
|
|
36
|
+
left: -100%;
|
|
37
|
+
}
|
|
38
|
+
._1uQwZ {
|
|
39
|
+
left: 100%;
|
|
40
|
+
}
|
|
41
|
+
._18Pcq {
|
|
42
|
+
transition: left 0.4s ease-in 0s;
|
|
43
|
+
}
|
|
44
|
+
._1nj1b {
|
|
45
|
+
transition: left 0.4s ease-out 0s;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
._3cLUl {
|
|
49
|
+
width: 100%;
|
|
50
|
+
height: 100%;
|
|
51
|
+
position: relative;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
._2jwZj {
|
|
55
|
+
border-radius: 2px;
|
|
56
|
+
position: relative;
|
|
57
|
+
width: calc(100% - 48px);
|
|
58
|
+
height: calc(100% - 48px);
|
|
59
|
+
box-shadow: 0px 0px 5px 1px rgba(34, 60, 80, 0.14);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
._2hTXI {
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
position: absolute;
|
|
65
|
+
width: auto;
|
|
66
|
+
height: auto;
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
z-index: 12;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
._2Z7EZ {
|
|
73
|
+
right: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
._2Xedt {
|
|
77
|
+
left: 0;
|
|
78
|
+
transform: rotate(180deg);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
._2J4XS {
|
|
82
|
+
display: inline-flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
position: relative;
|
|
86
|
+
box-sizing: border-box;
|
|
87
|
+
background-color: transparent;
|
|
88
|
+
outline: 0;
|
|
89
|
+
border: 0;
|
|
90
|
+
margin: 0;
|
|
91
|
+
border-radius: 0;
|
|
92
|
+
padding: 0;
|
|
93
|
+
cursor: pointer;
|
|
94
|
+
-webkit-user-select: none;
|
|
95
|
+
-moz-user-select: none;
|
|
96
|
+
-ms-user-select: none;
|
|
97
|
+
user-select: none;
|
|
98
|
+
vertical-align: middle;
|
|
99
|
+
text-decoration: none;
|
|
100
|
+
color: inherit;
|
|
101
|
+
text-align: center;
|
|
102
|
+
flex: 0 0 auto;
|
|
103
|
+
font-size: 1.5rem;
|
|
104
|
+
padding: 8px;
|
|
105
|
+
border-radius: 50%;
|
|
106
|
+
overflow: visible;
|
|
107
|
+
color: rgba(0, 0, 0, 0.54);
|
|
108
|
+
transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
109
|
+
}
|
|
110
|
+
._2J4XS:hover {
|
|
111
|
+
background-color: rgba(0, 0, 0, 0.054);
|
|
112
|
+
}
|
|
113
|
+
._2J4XS:active {
|
|
114
|
+
background-color: rgba(0, 0, 0, 0.007);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
._3MuXE {
|
|
118
|
+
position: absolute;
|
|
119
|
+
display: flex;
|
|
120
|
+
flex-direction: row;
|
|
121
|
+
bottom: 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
._3U2py {
|
|
125
|
+
cursor: pointer;
|
|
126
|
+
position: relative;
|
|
127
|
+
width: 8px;
|
|
128
|
+
height: 8px;
|
|
129
|
+
margin: 2px;
|
|
130
|
+
border: 1px solid gray;
|
|
131
|
+
border-radius: 50%;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
._3U2py._3sodH {
|
|
135
|
+
cursor: default;
|
|
136
|
+
background-color: gray;
|
|
137
137
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ import React, { RefObject } from 'react';
|
|
|
12
12
|
* Time to miliseconds of change animation by card left value
|
|
13
13
|
*/
|
|
14
14
|
export declare const SWIPE_TRANSITION_TIMEOUT = 400;
|
|
15
|
+
/**
|
|
16
|
+
* Minimum swipe speed regardless of distance
|
|
17
|
+
*/
|
|
18
|
+
export declare const SWIPE_ON_EVENT_SPEED = 0.7;
|
|
15
19
|
/**
|
|
16
20
|
* One of swipe card
|
|
17
21
|
*/
|
package/dist/index.js
CHANGED
|
@@ -200,6 +200,7 @@ function _switch(discriminant, cases) {
|
|
|
200
200
|
var s = {"container":"_1Lxpd","paper":"_8Yd7S","pipe":"_3uH2i","card":"_xsi02","prev":"_KqFRp","next":"_1uQwZ","back":"_18Pcq","go":"_1nj1b","card__stop":"_3cLUl","content":"_2jwZj","button":"_2hTXI","button__next":"_2Z7EZ","button__prev":"_2Xedt","icon__button":"_2J4XS","dots":"_3MuXE","dot":"_3U2py","active":"_3sodH"};
|
|
201
201
|
|
|
202
202
|
var SWIPE_TRANSITION_TIMEOUT = 400;
|
|
203
|
+
var SWIPE_ON_EVENT_SPEED = 0.7;
|
|
203
204
|
|
|
204
205
|
var getSwipes = function getSwipes(prev, current, next, swipes) {
|
|
205
206
|
if (((prev === null || prev === void 0 ? void 0 : prev.id) === (current === null || current === void 0 ? void 0 : current.id) || (current === null || current === void 0 ? void 0 : current.id) === (next === null || next === void 0 ? void 0 : next.id) || (next === null || next === void 0 ? void 0 : next.id) === (prev === null || prev === void 0 ? void 0 : prev.id)) && swipes.length) {
|
|
@@ -232,6 +233,7 @@ var postNext = null;
|
|
|
232
233
|
var _defaultCurrent;
|
|
233
234
|
|
|
234
235
|
var oldSwipes = [];
|
|
236
|
+
var startTime = new Date().getTime();
|
|
235
237
|
var Swiper = function Swiper(props) {
|
|
236
238
|
var defaultCurrent = props.defaultCurrent,
|
|
237
239
|
getNext = props.getNext,
|
|
@@ -355,7 +357,12 @@ var Swiper = function Swiper(props) {
|
|
|
355
357
|
}
|
|
356
358
|
};
|
|
357
359
|
|
|
358
|
-
var swipe = function swipe(
|
|
360
|
+
var swipe = function swipe(_ref) {
|
|
361
|
+
var _lastLeft = _ref._lastLeft,
|
|
362
|
+
_next = _ref._next,
|
|
363
|
+
_prev = _ref._prev,
|
|
364
|
+
speed = _ref.speed;
|
|
365
|
+
|
|
359
366
|
try {
|
|
360
367
|
var _temp7 = function _temp7(_result2) {
|
|
361
368
|
if (_exit2) return _result2;
|
|
@@ -365,15 +372,17 @@ var Swiper = function Swiper(props) {
|
|
|
365
372
|
|
|
366
373
|
var _exit2 = false;
|
|
367
374
|
setLoad(true);
|
|
368
|
-
|
|
375
|
+
|
|
376
|
+
var _startTime;
|
|
377
|
+
|
|
369
378
|
var currentId = 0;
|
|
370
379
|
|
|
371
380
|
var _temp8 = function () {
|
|
372
|
-
if (Math.abs(_lastLeft) > width / 3) {
|
|
381
|
+
if (Math.abs(_lastLeft) > width / 3 || speed !== undefined && speed > SWIPE_ON_EVENT_SPEED) {
|
|
373
382
|
return function () {
|
|
374
383
|
if (_lastLeft < 0) {
|
|
375
384
|
var _temp9 = function _temp9() {
|
|
376
|
-
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT - (new Date().getTime() -
|
|
385
|
+
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT - (new Date().getTime() - _startTime))).then(function () {
|
|
377
386
|
setLeft(0);
|
|
378
387
|
setPrev(current);
|
|
379
388
|
setCurrent(_next || next);
|
|
@@ -397,7 +406,7 @@ var Swiper = function Swiper(props) {
|
|
|
397
406
|
|
|
398
407
|
setGoClassHandler(_next);
|
|
399
408
|
setLeft(windowWidth * -1);
|
|
400
|
-
|
|
409
|
+
_startTime = new Date().getTime();
|
|
401
410
|
|
|
402
411
|
var _temp10 = function () {
|
|
403
412
|
var _postNext;
|
|
@@ -419,7 +428,7 @@ var Swiper = function Swiper(props) {
|
|
|
419
428
|
return _temp10 && _temp10.then ? _temp10.then(_temp9) : _temp9(_temp10);
|
|
420
429
|
} else {
|
|
421
430
|
var _temp11 = function _temp11() {
|
|
422
|
-
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT - (new Date().getTime() -
|
|
431
|
+
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT - (new Date().getTime() - _startTime))).then(function () {
|
|
423
432
|
setLeft(0);
|
|
424
433
|
setPrev(prePrev);
|
|
425
434
|
setCurrent(_prev || prev);
|
|
@@ -443,7 +452,7 @@ var Swiper = function Swiper(props) {
|
|
|
443
452
|
|
|
444
453
|
setGoClassHandler(undefined, _prev);
|
|
445
454
|
setLeft(windowWidth);
|
|
446
|
-
|
|
455
|
+
_startTime = new Date().getTime();
|
|
447
456
|
|
|
448
457
|
var _temp12 = function () {
|
|
449
458
|
var _prePrev;
|
|
@@ -503,6 +512,7 @@ var Swiper = function Swiper(props) {
|
|
|
503
512
|
startClientX = clientX;
|
|
504
513
|
startClientY = clientY;
|
|
505
514
|
lastLeft = _left;
|
|
515
|
+
startTime = new Date().getTime();
|
|
506
516
|
_interrupt2 = true;
|
|
507
517
|
}], [function () {
|
|
508
518
|
return 'onTouchMove';
|
|
@@ -523,7 +533,10 @@ var Swiper = function Swiper(props) {
|
|
|
523
533
|
}, function () {
|
|
524
534
|
var _temp13 = function () {
|
|
525
535
|
if (!blockSwipe) {
|
|
526
|
-
return Promise.resolve(swipe(
|
|
536
|
+
return Promise.resolve(swipe({
|
|
537
|
+
_lastLeft: lastLeft,
|
|
538
|
+
speed: Math.abs(lastLeft / (new Date().getTime() - startTime))
|
|
539
|
+
})).then(function () {});
|
|
527
540
|
}
|
|
528
541
|
}();
|
|
529
542
|
|
|
@@ -556,7 +569,9 @@ var Swiper = function Swiper(props) {
|
|
|
556
569
|
}
|
|
557
570
|
|
|
558
571
|
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT)).then(function () {
|
|
559
|
-
return Promise.resolve(swipe(
|
|
572
|
+
return Promise.resolve(swipe({
|
|
573
|
+
_lastLeft: leftVal
|
|
574
|
+
})).then(function () {
|
|
560
575
|
return 0;
|
|
561
576
|
});
|
|
562
577
|
});
|
|
@@ -676,7 +691,11 @@ var Swiper = function Swiper(props) {
|
|
|
676
691
|
return Promise.resolve(getNext(active - 1)).then(function (next) {
|
|
677
692
|
setNext(next);
|
|
678
693
|
return Promise.resolve(getPrev((next === null || next === void 0 ? void 0 : next.id) || 0)).then(function (prev) {
|
|
679
|
-
return Promise.resolve(swipe(
|
|
694
|
+
return Promise.resolve(swipe({
|
|
695
|
+
_lastLeft: -1000,
|
|
696
|
+
_prev: prev,
|
|
697
|
+
_next: next
|
|
698
|
+
})).then(function () {
|
|
680
699
|
return Promise.resolve(getNext((next === null || next === void 0 ? void 0 : next.id) || 0)).then(function (_getNext2) {
|
|
681
700
|
postNext = _getNext2;
|
|
682
701
|
return Promise.resolve(getPrev((prev === null || prev === void 0 ? void 0 : prev.id) || 0)).then(function (_getPrev2) {
|
|
@@ -691,7 +710,11 @@ var Swiper = function Swiper(props) {
|
|
|
691
710
|
return Promise.resolve(getPrev(active + 1)).then(function (prev) {
|
|
692
711
|
setPrev(prev);
|
|
693
712
|
return Promise.resolve(getNext((prev === null || prev === void 0 ? void 0 : prev.id) || 0)).then(function (next) {
|
|
694
|
-
return Promise.resolve(swipe(
|
|
713
|
+
return Promise.resolve(swipe({
|
|
714
|
+
_lastLeft: 1000,
|
|
715
|
+
_prev: prev,
|
|
716
|
+
_next: next
|
|
717
|
+
})).then(function () {
|
|
695
718
|
return Promise.resolve(getNext((next === null || next === void 0 ? void 0 : next.id) || 0)).then(function (_getNext3) {
|
|
696
719
|
postNext = _getNext3;
|
|
697
720
|
return Promise.resolve(getPrev((prev === null || prev === void 0 ? void 0 : prev.id) || 0)).then(function (_getPrev3) {
|
|
@@ -885,6 +908,7 @@ Swiper.defaultProps = {
|
|
|
885
908
|
className: ''
|
|
886
909
|
};
|
|
887
910
|
|
|
911
|
+
exports.SWIPE_ON_EVENT_SPEED = SWIPE_ON_EVENT_SPEED;
|
|
888
912
|
exports.SWIPE_TRANSITION_TIMEOUT = SWIPE_TRANSITION_TIMEOUT;
|
|
889
913
|
exports.Swiper = Swiper;
|
|
890
914
|
//# sourceMappingURL=index.js.map
|