1 |
|
2 | "use strict";
|
3 |
|
4 | const { SvelteComponent, assign, attr, binding_callbacks, check_outros, compute_rest_props, create_slot, detach, element, exclude_internal_props, get_spread_update, group_outros, init, insert, safe_not_equal, set_attributes, transition_in, transition_out, update_slot } = require("svelte/internal");
|
5 | const { onMount, onDestroy, beforeUpdate, afterUpdate, tick } = require("svelte");
|
6 | const { uniqueClasses } = require("./utils");
|
7 | const get_default_slot_changes_1 = dirty => ({ data: dirty & 32 });
|
8 | const get_default_slot_context_1 = ctx => ({ data: ctx[5] });
|
9 | const get_default_slot_changes = dirty => ({ data: dirty & 32 });
|
10 | const get_default_slot_context = ctx => ({ data: ctx[5] });
|
11 |
|
12 |
|
13 | function create_else_block(ctx) {
|
14 | let current;
|
15 | const default_slot_template = ctx[8].default;
|
16 | const default_slot = create_slot(default_slot_template, ctx, ctx[7], get_default_slot_context_1);
|
17 |
|
18 | return {
|
19 | c() {
|
20 | if (default_slot) default_slot.c();
|
21 | },
|
22 | m(target, anchor) {
|
23 | if (default_slot) {
|
24 | default_slot.m(target, anchor);
|
25 | }
|
26 |
|
27 | current = true;
|
28 | },
|
29 | p(ctx, dirty) {
|
30 | if (default_slot) {
|
31 | if (default_slot.p && dirty & 160) {
|
32 | update_slot(default_slot, default_slot_template, ctx, ctx[7], dirty, get_default_slot_changes_1, get_default_slot_context_1);
|
33 | }
|
34 | }
|
35 | },
|
36 | i(local) {
|
37 | if (current) return;
|
38 | transition_in(default_slot, local);
|
39 | current = true;
|
40 | },
|
41 | o(local) {
|
42 | transition_out(default_slot, local);
|
43 | current = false;
|
44 | },
|
45 | d(detaching) {
|
46 | if (default_slot) default_slot.d(detaching);
|
47 | }
|
48 | };
|
49 | }
|
50 |
|
51 |
|
52 | function create_if_block(ctx) {
|
53 | let div;
|
54 | let div_data_swiper_zoom_value;
|
55 | let current;
|
56 | const default_slot_template = ctx[8].default;
|
57 | const default_slot = create_slot(default_slot_template, ctx, ctx[7], get_default_slot_context);
|
58 |
|
59 | return {
|
60 | c() {
|
61 | div = element("div");
|
62 | if (default_slot) default_slot.c();
|
63 | attr(div, "class", "swiper-zoom-container");
|
64 |
|
65 | attr(div, "data-swiper-zoom", div_data_swiper_zoom_value = typeof ctx[0] === "number"
|
66 | ? ctx[0]
|
67 | : undefined);
|
68 | },
|
69 | m(target, anchor) {
|
70 | insert(target, div, anchor);
|
71 |
|
72 | if (default_slot) {
|
73 | default_slot.m(div, null);
|
74 | }
|
75 |
|
76 | current = true;
|
77 | },
|
78 | p(ctx, dirty) {
|
79 | if (default_slot) {
|
80 | if (default_slot.p && dirty & 160) {
|
81 | update_slot(default_slot, default_slot_template, ctx, ctx[7], dirty, get_default_slot_changes, get_default_slot_context);
|
82 | }
|
83 | }
|
84 |
|
85 | if (!current || dirty & 1 && div_data_swiper_zoom_value !== (div_data_swiper_zoom_value = typeof ctx[0] === "number"
|
86 | ? ctx[0]
|
87 | : undefined)) {
|
88 | attr(div, "data-swiper-zoom", div_data_swiper_zoom_value);
|
89 | }
|
90 | },
|
91 | i(local) {
|
92 | if (current) return;
|
93 | transition_in(default_slot, local);
|
94 | current = true;
|
95 | },
|
96 | o(local) {
|
97 | transition_out(default_slot, local);
|
98 | current = false;
|
99 | },
|
100 | d(detaching) {
|
101 | if (detaching) detach(div);
|
102 | if (default_slot) default_slot.d(detaching);
|
103 | }
|
104 | };
|
105 | }
|
106 |
|
107 | function create_fragment(ctx) {
|
108 | let div;
|
109 | let current_block_type_index;
|
110 | let if_block;
|
111 | let div_class_value;
|
112 | let current;
|
113 | const if_block_creators = [create_if_block, create_else_block];
|
114 | const if_blocks = [];
|
115 |
|
116 | function select_block_type(ctx, dirty) {
|
117 | if ( ctx[0]) return 0;
|
118 | return 1;
|
119 | }
|
120 |
|
121 | current_block_type_index = select_block_type(ctx, -1);
|
122 | if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
|
123 |
|
124 | let div_levels = [
|
125 | {
|
126 | class: div_class_value = uniqueClasses(`${/*slideClasses*/ ctx[4]}${/*className*/ ctx[2] ? ` ${/*className*/ ctx[2]}` : ""}`)
|
127 | },
|
128 | {
|
129 | "data-swiper-slide-index": ctx[1]
|
130 | },
|
131 | ctx[6]
|
132 | ];
|
133 |
|
134 | let div_data = {};
|
135 |
|
136 | for (let i = 0; i < div_levels.length; i += 1) {
|
137 | div_data = assign(div_data, div_levels[i]);
|
138 | }
|
139 |
|
140 | return {
|
141 | c() {
|
142 | div = element("div");
|
143 | if_block.c();
|
144 | set_attributes(div, div_data);
|
145 | },
|
146 | m(target, anchor) {
|
147 | insert(target, div, anchor);
|
148 | if_blocks[current_block_type_index].m(div, null);
|
149 | ctx[9](div);
|
150 | current = true;
|
151 | },
|
152 | p(ctx, [dirty]) {
|
153 | let previous_block_index = current_block_type_index;
|
154 | current_block_type_index = select_block_type(ctx, dirty);
|
155 |
|
156 | if (current_block_type_index === previous_block_index) {
|
157 | if_blocks[current_block_type_index].p(ctx, dirty);
|
158 | } else {
|
159 | group_outros();
|
160 |
|
161 | transition_out(if_blocks[previous_block_index], 1, 1, () => {
|
162 | if_blocks[previous_block_index] = null;
|
163 | });
|
164 |
|
165 | check_outros();
|
166 | if_block = if_blocks[current_block_type_index];
|
167 |
|
168 | if (!if_block) {
|
169 | if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
|
170 | if_block.c();
|
171 | }
|
172 |
|
173 | transition_in(if_block, 1);
|
174 | if_block.m(div, null);
|
175 | }
|
176 |
|
177 | set_attributes(div, div_data = get_spread_update(div_levels, [
|
178 | (!current || dirty & 20 && div_class_value !== (div_class_value = uniqueClasses(`${/*slideClasses*/ ctx[4]}${/*className*/ ctx[2] ? ` ${/*className*/ ctx[2]}` : ""}`))) && { class: div_class_value },
|
179 | (!current || dirty & 2) && {
|
180 | "data-swiper-slide-index": ctx[1]
|
181 | },
|
182 | dirty & 64 && ctx[6]
|
183 | ]));
|
184 | },
|
185 | i(local) {
|
186 | if (current) return;
|
187 | transition_in(if_block);
|
188 | current = true;
|
189 | },
|
190 | o(local) {
|
191 | transition_out(if_block);
|
192 | current = false;
|
193 | },
|
194 | d(detaching) {
|
195 | if (detaching) detach(div);
|
196 | if_blocks[current_block_type_index].d();
|
197 | ctx[9](null);
|
198 | }
|
199 | };
|
200 | }
|
201 |
|
202 | function instance($$self, $$props, $$invalidate) {
|
203 | const omit_props_names = ["zoom","virtualIndex","class"];
|
204 | let $$restProps = compute_rest_props($$props, omit_props_names);
|
205 | let { zoom = undefined } = $$props;
|
206 | let { virtualIndex = undefined } = $$props;
|
207 | let { class: className = undefined } = $$props;
|
208 | let slideEl = null;
|
209 | let slideClasses = "swiper-slide";
|
210 | let swiper = null;
|
211 | let eventAttached = false;
|
212 |
|
213 | const updateClasses = (_, el, classNames) => {
|
214 | if (el === slideEl) {
|
215 | $$invalidate(4, slideClasses = classNames);
|
216 | }
|
217 | };
|
218 |
|
219 | const attachEvent = () => {
|
220 | if (!swiper || eventAttached) return;
|
221 | swiper.on("_slideClass", updateClasses);
|
222 | eventAttached = true;
|
223 | };
|
224 |
|
225 | const detachEvent = () => {
|
226 | if (!swiper) return;
|
227 | swiper.off("_slideClass", updateClasses);
|
228 | eventAttached = false;
|
229 | };
|
230 |
|
231 | onMount(() => {
|
232 | if (typeof virtualIndex === "undefined") return;
|
233 |
|
234 | $$invalidate(
|
235 | 3,
|
236 | slideEl.onSwiper = _swiper => {
|
237 | swiper = _swiper;
|
238 | attachEvent();
|
239 | },
|
240 | slideEl
|
241 | );
|
242 |
|
243 | attachEvent();
|
244 | });
|
245 |
|
246 | afterUpdate(() => {
|
247 | if (!slideEl || !swiper) return;
|
248 |
|
249 | if (swiper.destroyed) {
|
250 | if (slideClasses !== "swiper-slide") {
|
251 | $$invalidate(4, slideClasses = "swiper-slide");
|
252 | }
|
253 |
|
254 | return;
|
255 | }
|
256 |
|
257 | attachEvent();
|
258 | });
|
259 |
|
260 | beforeUpdate(() => {
|
261 | attachEvent();
|
262 | });
|
263 |
|
264 | onDestroy(() => {
|
265 | if (!swiper) return;
|
266 | detachEvent();
|
267 | });
|
268 |
|
269 | let { $$slots = {}, $$scope } = $$props;
|
270 |
|
271 | function div_binding($$value) {
|
272 | binding_callbacks[$$value ? "unshift" : "push"](() => {
|
273 | slideEl = $$value;
|
274 | $$invalidate(3, slideEl);
|
275 | });
|
276 | }
|
277 |
|
278 | $$self.$$set = $$new_props => {
|
279 | $$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
280 | $$invalidate(6, $$restProps = compute_rest_props($$props, omit_props_names));
|
281 | if ("zoom" in $$new_props) $$invalidate(0, zoom = $$new_props.zoom);
|
282 | if ("virtualIndex" in $$new_props) $$invalidate(1, virtualIndex = $$new_props.virtualIndex);
|
283 | if ("class" in $$new_props) $$invalidate(2, className = $$new_props.class);
|
284 | if ("$$scope" in $$new_props) $$invalidate(7, $$scope = $$new_props.$$scope);
|
285 | };
|
286 |
|
287 | let slideData;
|
288 |
|
289 | $$self.$$.update = () => {
|
290 | if ($$self.$$.dirty & 16) {
|
291 | $: $$invalidate(5, slideData = {
|
292 | isActive: slideClasses.indexOf("swiper-slide-active") >= 0 || slideClasses.indexOf("swiper-slide-duplicate-active") >= 0,
|
293 | isVisible: slideClasses.indexOf("swiper-slide-visible") >= 0,
|
294 | isDuplicate: slideClasses.indexOf("swiper-slide-duplicate") >= 0,
|
295 | isPrev: slideClasses.indexOf("swiper-slide-prev") >= 0 || slideClasses.indexOf("swiper-slide-duplicate-prev") >= 0,
|
296 | isNext: slideClasses.indexOf("swiper-slide-next") >= 0 || slideClasses.indexOf("swiper-slide-duplicate-next") >= 0
|
297 | });
|
298 | }
|
299 | };
|
300 |
|
301 | return [
|
302 | zoom,
|
303 | virtualIndex,
|
304 | className,
|
305 | slideEl,
|
306 | slideClasses,
|
307 | slideData,
|
308 | $$restProps,
|
309 | $$scope,
|
310 | $$slots,
|
311 | div_binding
|
312 | ];
|
313 | }
|
314 |
|
315 | class Swiper extends SvelteComponent {
|
316 | constructor(options) {
|
317 | super();
|
318 | init(this, options, instance, create_fragment, safe_not_equal, { zoom: 0, virtualIndex: 1, class: 2 });
|
319 | }
|
320 | }
|
321 |
|
322 | exports.default = Swiper; |
\ | No newline at end of file |