@loickit-v/swiper 0.0.2 → 0.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 +151 -0
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1 +1,152 @@
|
|
1
1
|
# @loickit-v/swiper
|
2
|
+
|
3
|
+
## Components
|
4
|
+
|
5
|
+
### LSlide
|
6
|
+
|
7
|
+
the Slide Component
|
8
|
+
|
9
|
+
#### Props
|
10
|
+
|
11
|
+
- name
|
12
|
+
|
13
|
+
identification of this slide, get by `defineSlide`
|
14
|
+
|
15
|
+
- list
|
16
|
+
\<Array>
|
17
|
+
|
18
|
+
just avaliable `infinite` mode, the long list of render, will cached by `slotScope.cacheList`
|
19
|
+
|
20
|
+
- loadMore
|
21
|
+
\<Function>
|
22
|
+
|
23
|
+
just avaliable `infinite` mode, when the pointer points to the cacheList end, will trigger.
|
24
|
+
|
25
|
+
#### Hooks
|
26
|
+
|
27
|
+
**defineSlide**
|
28
|
+
|
29
|
+
define a slide object
|
30
|
+
|
31
|
+
argument:
|
32
|
+
|
33
|
+
- provideKey \<Symbol> | <String>
|
34
|
+
|
35
|
+
the identification of target slide
|
36
|
+
|
37
|
+
return \[createSlide, useSlide]
|
38
|
+
|
39
|
+
- createSlide
|
40
|
+
|
41
|
+
create a slide states, use return value to registe a slide
|
42
|
+
|
43
|
+
params:
|
44
|
+
|
45
|
+
- initial \<SlideState>
|
46
|
+
|
47
|
+
- direction \<SLIDE\*DIRECTION> _optional_
|
48
|
+
|
49
|
+
default: SLIDE_DIRECTION.HORIZONTAL
|
50
|
+
|
51
|
+
direction
|
52
|
+
|
53
|
+
- currentIndex \<number> _optional_
|
54
|
+
|
55
|
+
pointer
|
56
|
+
|
57
|
+
- duration \<number> _optional_
|
58
|
+
|
59
|
+
slide switch animation duration
|
60
|
+
|
61
|
+
- infinite \<boolean> `infinite` _optional_
|
62
|
+
|
63
|
+
mode enable
|
64
|
+
|
65
|
+
return:
|
66
|
+
|
67
|
+
- name
|
68
|
+
|
69
|
+
the identification of target slide
|
70
|
+
|
71
|
+
- state \<SlideState>
|
72
|
+
|
73
|
+
the slide state
|
74
|
+
|
75
|
+
- useSlide
|
76
|
+
|
77
|
+
return: \<SlideSate>
|
78
|
+
|
79
|
+
#### Slot
|
80
|
+
|
81
|
+
**default**
|
82
|
+
|
83
|
+
- cacheList
|
84
|
+
|
85
|
+
the cache data of list, just cache 3, just avaliable `infinite` mode
|
86
|
+
|
87
|
+
### LSlideItem
|
88
|
+
|
89
|
+
#### Props
|
90
|
+
|
91
|
+
- index \<number> optional
|
92
|
+
|
93
|
+
the index of this slide item, required when `infinite` mode
|
94
|
+
|
95
|
+
### Usage
|
96
|
+
|
97
|
+
```vue
|
98
|
+
<script setup lang="ts">
|
99
|
+
import {
|
100
|
+
defineSlide,
|
101
|
+
LSlide,
|
102
|
+
LSlideItem,
|
103
|
+
SLIDE_DIRECTION
|
104
|
+
} from '@loickit-v/swiper';
|
105
|
+
|
106
|
+
defineOptions({ name: 'App' });
|
107
|
+
|
108
|
+
const [createSlide] = defineSlide('one');
|
109
|
+
|
110
|
+
const oneSlide = createSlide({
|
111
|
+
currentIndex: 1
|
112
|
+
});
|
113
|
+
|
114
|
+
const [createSlide2] = defineSlide('two');
|
115
|
+
|
116
|
+
const twoSlide = createSlide2({
|
117
|
+
direction: SLIDE_DIRECTION.VERTICAL
|
118
|
+
});
|
119
|
+
|
120
|
+
const oneToTwo = () => {
|
121
|
+
oneSlide.state.currentIndex = 2;
|
122
|
+
};
|
123
|
+
</script>
|
124
|
+
|
125
|
+
<template>
|
126
|
+
<LSlide :name="oneSlide.name">
|
127
|
+
<LSlideItem style="background-color: red; width: 30%">1</LSlideItem>
|
128
|
+
<LSlideItem style="background-color: blue">2</LSlideItem>
|
129
|
+
<LSlideItem style="background-color: green">
|
130
|
+
<LSlide :name="twoSlide.name">
|
131
|
+
<LSlideItem style="background-color: pink; height: 30%">1</LSlideItem>
|
132
|
+
<LSlideItem style="background-color: orange">2</LSlideItem>
|
133
|
+
<LSlideItem style="background-color: yellow">3</LSlideItem>
|
134
|
+
</LSlide>
|
135
|
+
</LSlideItem>
|
136
|
+
</LSlide>
|
137
|
+
|
138
|
+
<p>one currentIndex: {{ oneSlide.state.currentIndex }}</p>
|
139
|
+
<p>two currentIndex: {{ twoSlide.state.currentIndex }}</p>
|
140
|
+
|
141
|
+
<button @click="oneToTwo">click to two slide</button>
|
142
|
+
</template>
|
143
|
+
|
144
|
+
<style lang="scss">
|
145
|
+
body,
|
146
|
+
#app {
|
147
|
+
background-color: #ccc;
|
148
|
+
height: 800px;
|
149
|
+
width: 800px;
|
150
|
+
}
|
151
|
+
</style>
|
152
|
+
```
|