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