|
1 | 1 | <template> |
2 | 2 | <div class="infinite-loading-container"> |
3 | 3 | <div v-show="isLoading"> |
4 | | - <slot name="spinner"> |
5 | | - <component :is="spinnerView"></component> |
6 | | - </slot> |
| 4 | + <spinner :spinner="spinner" /> |
7 | 5 | </div> |
8 | 6 | <div class="infinite-status-prompt" v-show="isNoResults"> |
9 | 7 | <slot name="no-results">No results :(</slot> |
|
15 | 13 | </template> |
16 | 14 | <script> |
17 | 15 | /* eslint-disable no-console */ |
| 16 | + import Spinner from './Spinner'; |
18 | 17 |
|
19 | 18 | const LOOP_CHECK_TIMEOUT = 1000; // the timeout for check infinite loop |
20 | 19 | const LOOP_CHECK_MAX_CALLS = 10; // the maximum number of continuous calls |
21 | | - const SPINNERS = { |
22 | | - BUBBLES: { |
23 | | - render(createElement) { |
24 | | - return createElement('span', { |
25 | | - attrs: { |
26 | | - class: 'loading-bubbles', |
27 | | - }, |
28 | | - }, Array.apply(Array, Array(8)).map(() => createElement('span', { |
29 | | - attrs: { |
30 | | - class: 'bubble-item', |
31 | | - }, |
32 | | - })), |
33 | | - ); |
34 | | - }, |
35 | | - }, |
36 | | - CIRCLES: { |
37 | | - render(createElement) { |
38 | | - return createElement('span', { |
39 | | - attrs: { |
40 | | - class: 'loading-circles', |
41 | | - }, |
42 | | - }, Array.apply(Array, Array(8)).map(() => createElement('span', { |
43 | | - attrs: { |
44 | | - class: 'circle-item', |
45 | | - }, |
46 | | - })), |
47 | | - ); |
48 | | - }, |
49 | | - }, |
50 | | - DEFAULT: { |
51 | | - render(createElement) { |
52 | | - return createElement('i', { |
53 | | - attrs: { |
54 | | - class: 'loading-default', |
55 | | - }, |
56 | | - }); |
57 | | - }, |
58 | | - }, |
59 | | - SPIRAL: { |
60 | | - render(createElement) { |
61 | | - return createElement('i', { |
62 | | - attrs: { |
63 | | - class: 'loading-spiral', |
64 | | - }, |
65 | | - }); |
66 | | - }, |
67 | | - }, |
68 | | - WAVEDOTS: { |
69 | | - render(createElement) { |
70 | | - return createElement('span', { |
71 | | - attrs: { |
72 | | - class: 'loading-wave-dots', |
73 | | - }, |
74 | | - }, Array.apply(Array, Array(5)).map(() => createElement('span', { |
75 | | - attrs: { |
76 | | - class: 'wave-item', |
77 | | - }, |
78 | | - })), |
79 | | - ); |
80 | | - }, |
81 | | - }, |
82 | | - }; |
83 | 20 | const WARNINGS = { |
84 | 21 | STATE_CHANGER: [ |
85 | 22 | '[Vue-infinite-loading warn]: emit `loaded` and `complete` event through component instance of `$refs` may cause error, so it will be deprecated soon, please use the `$state` argument instead (`$state` just the special `$event` variable):', |
|
134 | 71 | continuousCallTimes: 0, |
135 | 72 | }; |
136 | 73 | }, |
| 74 | + components: { |
| 75 | + Spinner, |
| 76 | + }, |
137 | 77 | computed: { |
138 | | - spinnerView() { |
139 | | - return SPINNERS[(this.spinner || '').toUpperCase()] || SPINNERS.DEFAULT; |
140 | | - }, |
141 | 78 | isNoResults: { |
142 | 79 | cache: false, // disable cache to fix the problem of get slot text delay |
143 | 80 | get() { |
|
342 | 279 | }; |
343 | 280 | </script> |
344 | 281 | <style lang="less" scoped> |
345 | | - @import '../styles/spinner'; |
| 282 | + @deep: ~'>>>'; |
346 | 283 |
|
347 | 284 | .infinite-loading-container { |
348 | 285 | clear: both; |
|
0 commit comments