1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,93 +0,0 @@ |
1 |
-import { isObject, extend } from './utils'; |
|
2 |
- |
|
3 |
-function updateSwiper(swiper, slides, passedParams, changedParams) { |
|
4 |
- var updateParams = changedParams.filter(function (key) { |
|
5 |
- return key !== 'children' && key !== 'direction'; |
|
6 |
- }); |
|
7 |
- var currentParams = swiper.params, |
|
8 |
- pagination = swiper.pagination, |
|
9 |
- navigation = swiper.navigation, |
|
10 |
- scrollbar = swiper.scrollbar, |
|
11 |
- virtual = swiper.virtual, |
|
12 |
- thumbs = swiper.thumbs; |
|
13 |
- var needThumbsInit; |
|
14 |
- var needControllerInit; |
|
15 |
- var needPaginationInit; |
|
16 |
- var needScrollbarInit; |
|
17 |
- var needNavigationInit; |
|
18 |
- |
|
19 |
- if (changedParams.includes('thumbs') && passedParams.thumbs && passedParams.thumbs.swiper && currentParams.thumbs && !currentParams.thumbs.swiper) { |
|
20 |
- needThumbsInit = true; |
|
21 |
- } |
|
22 |
- |
|
23 |
- if (changedParams.includes('controller') && passedParams.controller && passedParams.controller.control && currentParams.controller && !currentParams.controller.control) { |
|
24 |
- needControllerInit = true; |
|
25 |
- } |
|
26 |
- |
|
27 |
- if (changedParams.includes('pagination') && passedParams.pagination && passedParams.pagination.el && currentParams.pagination && pagination && !pagination.el) { |
|
28 |
- needPaginationInit = true; |
|
29 |
- } |
|
30 |
- |
|
31 |
- if (changedParams.includes('scrollbar') && passedParams.scrollbar && passedParams.scrollbar.el && currentParams.scrollbar && scrollbar && !scrollbar.el) { |
|
32 |
- needScrollbarInit = true; |
|
33 |
- } |
|
34 |
- |
|
35 |
- if (changedParams.includes('navigation') && passedParams.navigation && passedParams.navigation.prevEl && passedParams.navigation.nextEl && currentParams.navigation && navigation && !navigation.prevEl && !navigation.nextEl) { |
|
36 |
- needNavigationInit = true; |
|
37 |
- } |
|
38 |
- |
|
39 |
- updateParams.forEach(function (key) { |
|
40 |
- if (isObject(currentParams[key]) && isObject(passedParams[key])) { |
|
41 |
- extend(currentParams[key], passedParams[key]); |
|
42 |
- } else { |
|
43 |
- currentParams[key] = passedParams[key]; |
|
44 |
- } |
|
45 |
- }); |
|
46 |
- |
|
47 |
- if (changedParams.includes('children') && virtual && currentParams.virtual.enabled) { |
|
48 |
- virtual.slides = slides; |
|
49 |
- virtual.update(true); |
|
50 |
- } |
|
51 |
- |
|
52 |
- if (needThumbsInit) { |
|
53 |
- var initialized = thumbs.init(); |
|
54 |
- if (initialized) thumbs.update(true); |
|
55 |
- } |
|
56 |
- |
|
57 |
- if (needControllerInit) { |
|
58 |
- swiper.controller.control = currentParams.controller.control; |
|
59 |
- } |
|
60 |
- |
|
61 |
- if (needPaginationInit) { |
|
62 |
- pagination.init(); |
|
63 |
- pagination.render(); |
|
64 |
- pagination.update(); |
|
65 |
- } |
|
66 |
- |
|
67 |
- if (needScrollbarInit) { |
|
68 |
- scrollbar.init(); |
|
69 |
- scrollbar.updateSize(); |
|
70 |
- scrollbar.setTranslate(); |
|
71 |
- } |
|
72 |
- |
|
73 |
- if (needNavigationInit) { |
|
74 |
- navigation.init(); |
|
75 |
- navigation.update(); |
|
76 |
- } |
|
77 |
- |
|
78 |
- if (changedParams.includes('allowSlideNext')) { |
|
79 |
- swiper.allowSlideNext = passedParams.allowSlideNext; |
|
80 |
- } |
|
81 |
- |
|
82 |
- if (changedParams.includes('allowSlidePrev')) { |
|
83 |
- swiper.allowSlidePrev = passedParams.allowSlidePrev; |
|
84 |
- } |
|
85 |
- |
|
86 |
- if (changedParams.includes('direction')) { |
|
87 |
- swiper.changeDirection(passedParams.direction, false); |
|
88 |
- } |
|
89 |
- |
|
90 |
- swiper.update(); |
|
91 |
-} |
|
92 |
- |
|
93 |
-export { updateSwiper }; |
|
94 | 0 |
\ No newline at end of file |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,93 @@ |
1 |
+import { isObject, extend } from './utils'; |
|
2 |
+ |
|
3 |
+function updateSwiper(swiper, slides, passedParams, changedParams) { |
|
4 |
+ var updateParams = changedParams.filter(function (key) { |
|
5 |
+ return key !== 'children' && key !== 'direction'; |
|
6 |
+ }); |
|
7 |
+ var currentParams = swiper.params, |
|
8 |
+ pagination = swiper.pagination, |
|
9 |
+ navigation = swiper.navigation, |
|
10 |
+ scrollbar = swiper.scrollbar, |
|
11 |
+ virtual = swiper.virtual, |
|
12 |
+ thumbs = swiper.thumbs; |
|
13 |
+ var needThumbsInit; |
|
14 |
+ var needControllerInit; |
|
15 |
+ var needPaginationInit; |
|
16 |
+ var needScrollbarInit; |
|
17 |
+ var needNavigationInit; |
|
18 |
+ |
|
19 |
+ if (changedParams.includes('thumbs') && passedParams.thumbs && passedParams.thumbs.swiper && currentParams.thumbs && !currentParams.thumbs.swiper) { |
|
20 |
+ needThumbsInit = true; |
|
21 |
+ } |
|
22 |
+ |
|
23 |
+ if (changedParams.includes('controller') && passedParams.controller && passedParams.controller.control && currentParams.controller && !currentParams.controller.control) { |
|
24 |
+ needControllerInit = true; |
|
25 |
+ } |
|
26 |
+ |
|
27 |
+ if (changedParams.includes('pagination') && passedParams.pagination && passedParams.pagination.el && currentParams.pagination && pagination && !pagination.el) { |
|
28 |
+ needPaginationInit = true; |
|
29 |
+ } |
|
30 |
+ |
|
31 |
+ if (changedParams.includes('scrollbar') && passedParams.scrollbar && passedParams.scrollbar.el && currentParams.scrollbar && scrollbar && !scrollbar.el) { |
|
32 |
+ needScrollbarInit = true; |
|
33 |
+ } |
|
34 |
+ |
|
35 |
+ if (changedParams.includes('navigation') && passedParams.navigation && passedParams.navigation.prevEl && passedParams.navigation.nextEl && currentParams.navigation && navigation && !navigation.prevEl && !navigation.nextEl) { |
|
36 |
+ needNavigationInit = true; |
|
37 |
+ } |
|
38 |
+ |
|
39 |
+ updateParams.forEach(function (key) { |
|
40 |
+ if (isObject(currentParams[key]) && isObject(passedParams[key])) { |
|
41 |
+ extend(currentParams[key], passedParams[key]); |
|
42 |
+ } else { |
|
43 |
+ currentParams[key] = passedParams[key]; |
|
44 |
+ } |
|
45 |
+ }); |
|
46 |
+ |
|
47 |
+ if (changedParams.includes('children') && virtual && currentParams.virtual.enabled) { |
|
48 |
+ virtual.slides = slides; |
|
49 |
+ virtual.update(true); |
|
50 |
+ } |
|
51 |
+ |
|
52 |
+ if (needThumbsInit) { |
|
53 |
+ var initialized = thumbs.init(); |
|
54 |
+ if (initialized) thumbs.update(true); |
|
55 |
+ } |
|
56 |
+ |
|
57 |
+ if (needControllerInit) { |
|
58 |
+ swiper.controller.control = currentParams.controller.control; |
|
59 |
+ } |
|
60 |
+ |
|
61 |
+ if (needPaginationInit) { |
|
62 |
+ pagination.init(); |
|
63 |
+ pagination.render(); |
|
64 |
+ pagination.update(); |
|
65 |
+ } |
|
66 |
+ |
|
67 |
+ if (needScrollbarInit) { |
|
68 |
+ scrollbar.init(); |
|
69 |
+ scrollbar.updateSize(); |
|
70 |
+ scrollbar.setTranslate(); |
|
71 |
+ } |
|
72 |
+ |
|
73 |
+ if (needNavigationInit) { |
|
74 |
+ navigation.init(); |
|
75 |
+ navigation.update(); |
|
76 |
+ } |
|
77 |
+ |
|
78 |
+ if (changedParams.includes('allowSlideNext')) { |
|
79 |
+ swiper.allowSlideNext = passedParams.allowSlideNext; |
|
80 |
+ } |
|
81 |
+ |
|
82 |
+ if (changedParams.includes('allowSlidePrev')) { |
|
83 |
+ swiper.allowSlidePrev = passedParams.allowSlidePrev; |
|
84 |
+ } |
|
85 |
+ |
|
86 |
+ if (changedParams.includes('direction')) { |
|
87 |
+ swiper.changeDirection(passedParams.direction, false); |
|
88 |
+ } |
|
89 |
+ |
|
90 |
+ swiper.update(); |
|
91 |
+} |
|
92 |
+ |
|
93 |
+export { updateSwiper }; |
|
0 | 94 |
\ No newline at end of file |