@kolserdav/swiper 3.0.2 → 3.0.3

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 CHANGED
@@ -1,106 +1,106 @@
1
- # swiper
2
-
3
- > Simple and powerfull dynamic react swiper component
4
-
5
- [![NPM](https://img.shields.io/npm/v/swiper.svg)](https://www.npmjs.com/package/swiper) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](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
-
104
- ## License
105
-
106
- MIT © [kolserdav](https://github.com/kolserdav)
1
+ # swiper
2
+
3
+ > Simple and powerfull dynamic react swiper component
4
+
5
+ [![NPM](https://img.shields.io/npm/v/swiper.svg)](https://www.npmjs.com/package/swiper) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](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
+
104
+ ## License
105
+
106
+ MIT © [kolserdav](https://github.com/kolserdav)
package/dist/index.css CHANGED
@@ -1,114 +1,114 @@
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
- }
34
- ._KqFRp {
35
- left: -100%;
36
- }
37
- ._1uQwZ {
38
- left: 100%;
39
- }
40
- ._18Pcq {
41
- transition: left 0.4s ease-in 0s;
42
- }
43
- ._1nj1b {
44
- transition: left 0.4s ease-out 0s;
45
- }
46
-
47
- ._3cLUl {
48
- width: 100%;
49
- height: 100%;
50
- position: relative;
51
- }
52
-
53
- ._2jwZj {
54
- border-radius: 2px;
55
- position: relative;
56
- width: calc(100% - 48px);
57
- height: calc(100% - 48px);
58
- box-shadow: 0px 0px 5px 1px rgba(34, 60, 80, 0.14);
59
- }
60
-
61
- ._2hTXI {
62
- cursor: pointer;
63
- position: absolute;
64
- width: auto;
65
- height: auto;
66
- display: flex;
67
- align-items: center;
68
- z-index: 12;
69
- }
70
-
71
- ._2Z7EZ {
72
- right: 0;
73
- }
74
-
75
- ._2Xedt {
76
- left: 0;
77
- transform: rotate(180deg);
78
- }
79
-
80
- ._2J4XS {
81
- display: inline-flex;
82
- align-items: center;
83
- justify-content: center;
84
- position: relative;
85
- box-sizing: border-box;
86
- background-color: transparent;
87
- outline: 0;
88
- border: 0;
89
- margin: 0;
90
- border-radius: 0;
91
- padding: 0;
92
- cursor: pointer;
93
- -webkit-user-select: none;
94
- -moz-user-select: none;
95
- -ms-user-select: none;
96
- user-select: none;
97
- vertical-align: middle;
98
- text-decoration: none;
99
- color: inherit;
100
- text-align: center;
101
- flex: 0 0 auto;
102
- font-size: 1.5rem;
103
- padding: 8px;
104
- border-radius: 50%;
105
- overflow: visible;
106
- color: rgba(0, 0, 0, 0.54);
107
- transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
108
- }
109
- ._2J4XS:hover {
110
- background-color: rgba(0, 0, 0, 0.054);
111
- }
112
- ._2J4XS:active {
113
- background-color: rgba(0, 0, 0, 0.007);
114
- }
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
+ }
34
+ ._KqFRp {
35
+ left: -100%;
36
+ }
37
+ ._1uQwZ {
38
+ left: 100%;
39
+ }
40
+ ._18Pcq {
41
+ transition: left 0.4s ease-in 0s;
42
+ }
43
+ ._1nj1b {
44
+ transition: left 0.4s ease-out 0s;
45
+ }
46
+
47
+ ._3cLUl {
48
+ width: 100%;
49
+ height: 100%;
50
+ position: relative;
51
+ }
52
+
53
+ ._2jwZj {
54
+ border-radius: 2px;
55
+ position: relative;
56
+ width: calc(100% - 48px);
57
+ height: calc(100% - 48px);
58
+ box-shadow: 0px 0px 5px 1px rgba(34, 60, 80, 0.14);
59
+ }
60
+
61
+ ._2hTXI {
62
+ cursor: pointer;
63
+ position: absolute;
64
+ width: auto;
65
+ height: auto;
66
+ display: flex;
67
+ align-items: center;
68
+ z-index: 12;
69
+ }
70
+
71
+ ._2Z7EZ {
72
+ right: 0;
73
+ }
74
+
75
+ ._2Xedt {
76
+ left: 0;
77
+ transform: rotate(180deg);
78
+ }
79
+
80
+ ._2J4XS {
81
+ display: inline-flex;
82
+ align-items: center;
83
+ justify-content: center;
84
+ position: relative;
85
+ box-sizing: border-box;
86
+ background-color: transparent;
87
+ outline: 0;
88
+ border: 0;
89
+ margin: 0;
90
+ border-radius: 0;
91
+ padding: 0;
92
+ cursor: pointer;
93
+ -webkit-user-select: none;
94
+ -moz-user-select: none;
95
+ -ms-user-select: none;
96
+ user-select: none;
97
+ vertical-align: middle;
98
+ text-decoration: none;
99
+ color: inherit;
100
+ text-align: center;
101
+ flex: 0 0 auto;
102
+ font-size: 1.5rem;
103
+ padding: 8px;
104
+ border-radius: 50%;
105
+ overflow: visible;
106
+ color: rgba(0, 0, 0, 0.54);
107
+ transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
108
+ }
109
+ ._2J4XS:hover {
110
+ background-color: rgba(0, 0, 0, 0.054);
111
+ }
112
+ ._2J4XS:active {
113
+ background-color: rgba(0, 0, 0, 0.007);
114
+ }
package/dist/index.js CHANGED
@@ -706,9 +706,9 @@ var Swiper = function Swiper(props) {
706
706
  }, swipes.map(function (item) {
707
707
  var _item$id;
708
708
 
709
- return React__default.createElement("div", {
709
+ return React__default.createElement(React.Fragment, {
710
710
  key: item.id
711
- }, React__default.createElement(React.Fragment, null, item.id !== null && item.children !== null && width && React__default.createElement("div", {
711
+ }, item.id !== null && item.children !== null && width && React__default.createElement("div", {
712
712
  onTouchMove: onTouchWrapper('onTouchMove'),
713
713
  onTouchStart: onTouchWrapper('onTouchStart'),
714
714
  onTouchEnd: onTouchWrapper('onTouchEnd'),
@@ -755,7 +755,7 @@ var Swiper = function Swiper(props) {
755
755
  viewBox: "0 0 16 16"
756
756
  }, React__default.createElement("path", {
757
757
  d: "M5 3.5h6A1.5 1.5 0 0 1 12.5 5v6a1.5 1.5 0 0 1-1.5 1.5H5A1.5 1.5 0 0 1 3.5 11V5A1.5 1.5 0 0 1 5 3.5z"
758
- }))))));
758
+ })))));
759
759
  }), typeof isMobile !== 'undefined' && !isMobile && (prev === null || prev === void 0 ? void 0 : prev.id) !== null && React__default.createElement("div", {
760
760
  className: clsx(s.button, s.button__prev)
761
761
  }, React__default.createElement("button", {